[英]Python 3.3 programs not working?
I've made a few programs in Python now, but I'm still pretty new. 我现在已经用Python编写了一些程序,但是我还是很新。 I've updated to 3.3, and most of my programs are broken.
我已经更新到3.3,并且我的大多数程序都已损坏。 I've replaced all of the
raw_input
s now with input
, but this still isn't working, and I get no errors. 我现在已经用
input
替换了所有raw_input
,但是仍然无法正常工作,并且没有错误。
Could one of you fine programmers help? 你们其中一位优秀的程序员能帮忙吗?
a = 1
while a < 10:
StartQ = input("Would you like to Start the program, or Exit it?\n")
if StartQ == "Exit":
break
elif StartQ == "Start":
AMSoD = input("Would you like to Add, Multiply, Subtract or Divide?\nPlease enter A, M, S or D.\n")
if AMSoD == "A":
Add1 = input("Add this: ")
Add2 = input("By this: ")
AddAnswer = int(Add1) + int(Add2)
AAnswer = Add1 + " " + "+" + " " + Add2 + " " + "=",AddAnswer
print(AAnswer)
print("The answer is:"),AddAnswer
elif AMSoD == "M":
Mul1 = input("Multiply this: ")
Mul2 = input("By this: ")
MulAnswer = int(Mul1) * int(Mul2)
MAnswer = Mul1 + " " + "*" + " " + Mul2 + " " + "=",MulAnswer
print(MAnswer)
print("The answer is:"), (MulAnswer)
elif AMSoD == "S":
Sub1 = input("Subtract this: ")
Sub2 = input("From this: ")
SubAnswer = int(Sub2) - int(Sub1)
SAnswer = Sub2 + " " + "-" + " " + Sub1 + " " + "=",SubAnswer
print(SAnswer)
print("The answer is:"), (SubAnswer)
elif AMSoD == "D":
Div1 = input("Divide this: ")
Div2 = input("By this: ")
DivAnswer = int(Div1) / int(Div2)
DAnswer = Div1 + " " + "/" + " " + Div2 + " " + "=",DivAnswer
print(DAnswer)
print("The answer is:"), (DivAnswer)
DivQoR = input("Would you like to Quit or restart?\nAnswer Quit or Restart.\n")
if DivQoR == "Restart":
a = 1
elif DivQoR == "Quit":
DivQoRAyS = input("Are you sure you want to quit? Answer Yes or No.\n")
if DivQoRAyS == "Yes":
break
elif DivQoRAyS == "No":
a = 1
Put all items you want to print in the parenthesis of the print()
function call: 将要打印的所有项目放在
print()
函数调用的括号中:
print("The answer is:", AddAnswer)
and 和
print("The answer is:", MulAnswer)
etc. 等等
Where you build your strings, it'd be easier to do so in the print()
function. 在哪里构建字符串,在
print()
函数中这样做会更容易。 Instead of 代替
AAnswer = Add1 + " " + "+" + " " + Add2 + " " + "=",AddAnswer
print(AAnswer)
(where you forgot to replace the last comma with +
), do this: (您忘了用
+
代替最后一个逗号),请执行以下操作:
print(Add1, '+', Add2, '=', AddAnswer)
and so on for the other options. 等等其他选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.