为了账号安全,请及时绑定邮箱和手机立即绑定

Python 聊天机器人数学函数

Python 聊天机器人数学函数

浮云间 2023-06-20 17:16:58
我正在用 Python 制作聊天机器人。我如何教我的聊天机器人为与之交谈的人做数学?我有办法让它使用 Python 数学函数(即 3 * 8)吗?
查看完整描述

1 回答

?
莫回无

TA贡献1865条经验 获得超7个赞

是的,做数学很容易,


乘法:


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)


查看完整回答
反对 回复 2023-06-20
  • 1 回答
  • 0 关注
  • 106 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信