Reputation: 1
Here is my code: I'm not sure what the problem is. It says invalid syntax on "def sub". I've looked everywhere and as far as I can tell, it is properly formatted for 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")
Upvotes: 0
Views: 533
Reputation: 507
All the prints like:
print add()
are missing the parenthesis. They should be:
print(add())
Same for all the prints
Upvotes: 2