我在Python 3.3.1版本的这个基本计算器程序中一直出错。我自己找不到问题,有人能帮助我吗?非常感谢你提前!
x=(input("Which operation would you like to perform?"))
if x=='Addition':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y+z
print(a)
elif x=='Subtraction':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y-z
print(a)
elif x=='Multiplication':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y*z
print(a)
elif x=='Division':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y/z
print(a)
答案 0 :(得分:0)
你的标签搞砸了我想,尝试这样的事情:
x=input("Which operation would you like to perform?")
if x=='Addition':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y+z
print(a)
elif x=='Subtraction':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y-z
print(a)
elif x=='Multiplication':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y*z
print(a)
elif x=='Division':
y=int(input("Enter the first number?"))
z=int(input("Enter the second number?"))
a=y/z
print(a)
答案 1 :(得分:-1)
x= raw_input("Which operation would you like to perform?")
将解决您的问题
编辑:在python 3中,将raw_input重命名为input()以使用eval(input(....))
引用http://docs.python.org/3.0/whatsnew/3.0.html#builtins
希望这有帮助