zedChigo
2014-06-11 03:35:34 UTC
I just made a calculator with if/else/elif statements,
but because I don't have a loop the program stops after I've done the equasion I need
How will I add a while loop statement to my code?
Here is my code:
print "1: Addition"
print "2: Subtraction"
print "3: Multiplication"
print "4: Dividing"
print "\n"
choice = int(raw_input("Which do you want? 1/2/3/4 \n Choice: "))
if choice == 1:
print "Now this is Addition"
a = raw_input("Choose your first number: ")
b = raw_input("Choose your second number: ")
c = float(a) + float(b)
print c
elif choice == 2:
print "This is Subtraction"
a = raw_input("Choose your first number: ")
b = raw_input("Choose your second number: ")
c = float(a) - float(b)
print c
elif choice == 3:
print "This is Multiplication"
a = raw_input("Choose your first number: ")
b = raw_input("Choose your second number: ")
c = float(a) * float(b)
print c
elif choice == 4:
print "This is Dividing"
a = raw_input("Choose your first number: ")
b = raw_input("Choose your second number: ")
c = float(a) / float(b)
print c
else:
print "This is wrong, try again"