Custom Search

Sunday, October 18, 2009

Calculator- No fuctions

loop = 1
choice = 0
while loop == 1:
print "1) Addition"
print "2) Subtraction"
print "3) Division"
print "4) Multiplication"
print "5) Exit"
choice = input("Choose your operation: ")
if choice == 1:
ax = input("Add this: ")
ay = input("To this: ")
print ax, "+", ay, "=", ax + ay
if choice == 2:
sx = input("Subtract this: ")
sy = input("From this: ")
print sx, "-", sy, "=", sx - sy
if choice == 3:
dx = input("Divide this: ")
dy = input("By this: ")
print dx, "/", dy, "=", dx / dy
if choice == 4:
mx = input("Multiply this: ")
my = input("With this: ")
print mx, "x", my, "=", mx * my
elif choice == 5:
loop = 0

print "----------------------------------------"
print "----------------------------------------"

No comments:

Post a Comment