提交 7495d098 编写于 作者: U u011283906

Auto Commit

上级 6347b381
def calculator():
while True:
num1 = float(input("请输入第一个数字: "))
operator = input("请输入运算符 (+, -, *, /): ")
num2 = float(input("请输入第二个数字: "))
if operator == '+':
result = num1 + num2
elif operator == '-':
result = num1 - num2
elif operator == '*':
result = num1 * num2
elif operator == '/':
result = num1 / num2
else:
print("无效的运算符")
continue
print("结果: " + str(result))
choice = input("继续计算吗?(y/n): ")
if choice.lower() != 'y':
break
calculator()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册