def remainder(*args): # 取余,取最后的
r = args[0]
for i in args[1::]:
r %= i
print(r)
def exponentiation(*args): # 取幂
e = args[0]
for i in args[1::]:
e **= i
print(e)
def integer_division(*args): #
i_d = args[0]
for i in args[1::]:
i_d //= i
print(i_d)
def addition(*args): # 加法
a = sum(args)
print(a)
def subtraction(*args): # 减法
s = args[0]
for i in args[1::]:
s -= i
print(s)
# module/计算机进阶版.py:18
def division(*args): # 除法
d = args[0]
for i in args[1::]:
d /= i
print(d)
def multiplication(*args): # 乘法
a = number1[0]
for i3 in args[1::]:
a *= i3
print(a)
print('高仿式计算机')
c = int(input('请选择你要进行的运算:1.加法 2
number = input('请先输入你的数据(用英文逗号隔开
number1 = [float(i1) for i1 in n
number2 = tuple(number1)
if c == 1:
addition(number2)
elif c == 2:
subtraction(*number2)
elif c == 3:
multiplication(*number2)
elif c == 4:
division(*number2)
elif c == 5:
remainder(*number2)
elif c == 6:
exponentiation(*number2)
elif c == 7:
integer_division(*number2)
else:
print('没有此选项')
仍然是重复的部分复制粘贴,有点麻烦,有没有同学指导一下怎么简化他们?