我在用Python做一个聊天机器人。我怎么能教我的聊天机器人为它说话的人做数学呢?我是否有办法让它使用Python数学函数(即3* 8)?
发布于 2020-08-25 09:45:43
是的,做数学很容易,
Multiplication:
input_0 = input("What is the first number you want to multiply")
input_1 = input("What is the second number you want to multiply")
answer = int(input_0) * int(input_1)
print(answer)部门:
input_0 = input("What is the first number you want to divide")
input_1 = input("What is the second number you want to divide")
answer = int(input_0) / int(input_1)
print(answer)加法:
input_0 = input("What is the first number you want to add")
input_1 = input("What is the second number you want to add")
answer = int(input_0) + int(input_1)
print(answer)减法:
input_0 = input("What is the first number you want to subtract")
input_1 = input("What is the second number you want to subtract")
answer = int(input_0) - int(input_1)
print(answer)https://stackoverflow.com/questions/63575944
复制相似问题