如何解决Python Chatbot数学函数
我正在用Python创建一个聊天机器人。我该如何教我的聊天机器人为正在聊天的人做数学?我有办法让它使用Python数学函数(即3 * 8)吗?
解决方法
是的,很容易做数学,
乘法:
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)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。