keepProgramRunning = True
while keepProgramRunning:
print "Welcome to the Calculator!"
print "Please choose what you'd like to do:"
print "0: Addition"
print "1: Subtraction"
print "2: Multiplication"
print "3: Division"
#Capture the menu choice.
choice = raw_input()
#Capture the numbers you want to work with.
numberA = raw_input("Enter your first number: ")
numberB = raw_input("Enter your second number: ")
if choice == "0":
print "Your result is:"
print Addition(numberA, numberB)
elif choice == "1":
print "Your result is:"
print Subtraction(numberA, numberB)
elif choice == "2":
print "Your result is:"
print Multiplication(numberA, numberB)
elif choice == "3":
print "Your result is:"
print Division(numberA, numberB)
else:
print "Please choose a valid option."
def Addition(a, b):
return a + b
def Subtraction(a, b):
return a - b
def Multiplication(a, b):
return a * b
def Division(a, b):
return a / b
Here's the error:
Traceback (most recent call last):
File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\Tutorials\src\tutorials.py", line 23, in <module>
print Addition(numberA, numberB)
NameError: name 'Addition' is not defined
Thanks for the help!
Ps. I realize the loop will never end, I haven't added the menu option yet. :P