import time
while 1:
print '---------------科学计算器------------'
a=float(input('请输入第一个数字:'))
c=raw_input('请输入+ - * /:')
d=['+','-','*','/']
while c not in d:
print '算术输入格式错误请重新输入'
c=raw_input('请输入+ - * /:')
b=float(input('请输入第二个数字:'))
def add(d,e):
time.sleep(2)
print '计算结果:',float(d+e)
return d+e
def minus(f,g):
time.sleep(2)
print '计算结果:',float(f-g)
return float(f-g)
def mult(h,i):
time.sleep(2)
print '计算结果:',float(h*i)
return h*i
def chu(j,k):
time.sleep(2)
try:
m=j/k
print '计算结果:',float(m)
except ZeroDivisionError:
print '零不能做除数'
if c in d:
if c=='+':
add(a,b)
elif c=='/':
chu(a,b)
elif c=='-':
minus(a,b)
elif c=='*':
mult(a,b)