浙大版《Python 程序设计》题目集第5章-3 四则运算(用字典实现) (30 分)
a=int(input())
s=input()
b=int(input())
res={'+':'a+b','-':'a-b','*':'a*b','/':"a/b if b!=0 else 'divided by zero'"}
r=eval(res[s])
if type(r)==str:
print(r)
else:
print(format(r,'.2f'))
浙大版《Python 程序设计》题目集第5章-3 四则运算(用字典实现) (30 分)
a=int(input())
s=input()
b=int(input())
res={'+':'a+b','-':'a-b','*':'a*b','/':"a/b if b!=0 else 'divided by zero'"}
r=eval(res[s])
if type(r)==str:
print(r)
else:
print(format(r,'.2f'))