def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
if y == 0:
return "除数不能为0!"
return x / y
def floor_divide(x, y):
if y == 0:
return "除数不能为0!"
return x // y
def modulo(x, y):
if y == 0:
return "除数不能为0!"
return x % y
print("请选择操作:")
print("1.加法")
print("2.减法")
print("3.乘法")
print("4.除法")
print("5.整除")
print("6.求余数")
choice = input("请输入你的选择(1/2/3/4/5/6): ")
num1 = float(input("请输入第一个数: "))
num2 = float(input("请输入第二个数: "))
if choice == '1':
print("结果: ", add(num1, num2))
elif choice == '2':
print("结果: ", subtract(num1, num2))
elif choice == '3':
print("结果: ", multiply(num1, num2))
elif choice == '4':
print("结果: ", divide(num1, num2))
elif choice == '5':
print("结果: ", floor_divide(num1, num2))
elif choice == '6':
print("结果: ", modulo(num1, num2))
else:
print("输入错误,请输入正确的选项(1/2/3/4/5/6)。")