如何用python编辑计算器
1个回答
展开全部
def cal():
numA = float(raw_input('Please enter a number: '))
op = raw_input('Please enter a operator: ')
numB = float(raw_input('Please enter another number: '))
if op == '+':
print "result: ",numA+numB
elif op == '-':
print "result: ",numA-numB
elif op == '*':
print "result: ",numA*numB
elif op == '/':
print "result: ",numA/numB
else:
print "Unknown operator ",op
cal()
numA = float(raw_input('Please enter a number: '))
op = raw_input('Please enter a operator: ')
numB = float(raw_input('Please enter another number: '))
if op == '+':
print "result: ",numA+numB
elif op == '-':
print "result: ",numA-numB
elif op == '*':
print "result: ",numA*numB
elif op == '/':
print "result: ",numA/numB
else:
print "Unknown operator ",op
cal()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询