#变量定义
Add = 0
Reduce = 0
Take = 0
Remove = 0
#函数定义
def addition (Addend1,Addend2):
global Add
Add = Addend1 + Addend2
return Add
def subtraction (subtrahend1,subtrahend2):
global Reduce
Reduce = Asubtrahend1 - subtrahend2
return Reduce
def multiplication (multiplier1,multiplier2):
global Take
Take = multiplier1 * multiplier2
return Take
def division (divisor1,divisor2):
global Remove
Remove = divisor1 / divisor2
return Remove
#主要代码
print('计算器已开启')
print('注*:本机只支持两数运算!')
while True:
print('请选择运算符号(文字)')
a = input()
if a == 'M+' or a == 'm+':
print('请输入要储存的数')
k = input()
k = float(k)
elif a == 'MC' or a == 'mc':
k = ''
if a == '加':
print('请输入第一个数')
b = input()
if b == 'MR' or b == 'mr':
b = k
else:
b = float(b)
print('请输入第二个数')
c = input()
if c == 'MR' or c == 'mr':
c = k
else:
c = float(c)
d = addition(b,c)
print(d)
elif a == '减':
print('请输入第一个数')
b = input()
if b == 'MR' or b == 'mr':
b = k
else:
b = float(b)
print('请输入第二个数')
c = input()
if c == 'MR' or c == 'mr':
c = k
else:
c = float(c)
d = subtraction(b,c)
print(d)
elif a == '乘':
print('请输入第一个数')
b = input()
if b == 'MR' or b == 'mr':
b = k
else:
b = float(b)
print('请输入第二个数')
c = input()
if c == 'MR' or c == 'mr':
c = k
else:
c = float(c)
d = multiplication(b,c)
print(d)
elif a == '除':
print('请输入第一个数')
b = input()
if b == 'MR' or b == 'mr':
b = k
else:
b = float(b)
print('请输入第二个数')
c = input()
if c == 'MR' or c == 'mr':
c = k
else:
c = float(c)
d = division(b,c)
print(d)
elif a == '有余数除法':
print('注:输出第一行是商,第二行是余数')
print('请输入第一个数')
b = input()
if b == 'MR' or b == 'mr':
b = k
else:
b = float(b)
print('请输入第二个数')
c = input()
if c == 'MR' or c == 'mr':
c = k
else:
c = float(c)
d = b//c
e = b%c
print(d)
print(e)
elif a == 'STAR' or a == 'star' or a == '停止':
break
elif a == 'reset' or a == 'RESET' or a == '清零':
continue