Python 实现简单整数计算器
def calculator(): num1 = int(input()) num2 = int(input()) operator = input()
if operator == '+':
print(num1 + num2)
elif operator == '-':
print(num1 - num2)
elif operator == '*':
print(num1 * num2)
elif operator == '/':
if num2 == 0:
print('Divided by zero!')
else:
print(num1 / num2)
else:
print('Invalid operator!')
calculator()
原文地址: https://www.cveoy.top/t/topic/o1cY 著作权归作者所有。请勿转载和采集!