这是我的代码:我不确定问题是什么。它表示“def sub”上的语法无效。我到处都看,据我所知,它的格式正确为python 3
def add():
print ("Enter the two numbers to Add")
A=int(raw_input("Enter A: "))
B=int(raw_input("Enter B: "))
return A + B
def sub():
print ("Enter the two numbers to Subtract")
A=int(raw_input("Enter A: "))
B=int(raw_input("Enter B: "))
return A - B
def mul():
print ("Enter the two numbers to Multiply")
A=int(raw_input("Enter A: "))
B=int(raw_input("Enter B: "))
return A * B
def div():
print ("Enter the two number to Divide")
A=float(raw_input("Enter A: "))
B=float(raw_input("Enter B: "))
return A / B
print ("1: ADD")
print ("2: SUBTRACT")
print ("3: MULTIPLY")
print ("4: DIVIDE")
print ("0: QUIT")
while True:
CHOICE = int(raw_input("ENTER THE CORRESPONDING NUMBER FOR CALCULATION "))
if CHOICE == 1:
print ('ADD TWO NUMBERS:')
print add()
elif CHOICE == 2:
print ('SUBTRACT TWO NUMBERS')
print sub()
elif CHOICE == 3:
print ('MULTIPLY TWO NUMBERS')
print mul()
elif CHOICE == 4:
print ("DIVIDE TWO NUMBERS")
print div()
elif CHOICE == 0:
exit()
else:
print ("The value Enter value from 1-4")
答案 0 :(得分:2)
所有印刷品如:
print add()
缺少括号。他们应该是:
print(add())
所有版画相同