Glad I didn't put up my mini calculator apps on my site. Would have had complaints from people. But this thread has given me ideas on how to fix them all, and how to fix Giant Calculator as well. ----- Original Message ----- From: "Reed L. O'Brien" <[EMAIL PROTECTED]> To: "Nathan Pinno" <[EMAIL PROTECTED]> Sent: Saturday, July 30, 2005 9:05 PM Subject: Re: [Tutor] Now what do I do?(was Re: When I run this code, it just keeps repeating.)
> THis help? > > > # This is a small calculator. > def menu(): > print "CALCULATE MENU" > print "1) Add" > print "2) Subraction" > print "3) Multiplication" > print "4) Division w/o remainder" > print "5) Division with remaider" > print "6) Exponation" > print "7) Square roots" > print "9) Exit" > > def cal(): > cal_opt = int(raw_input("Option: ")) > return cal_opt > > print "Mini Calculator" > print "By Nathan Pinno" > print > while 1: ####################################<== here > menu() > cal_opt = cal() > if cal_opt == 1: > X = input("First number:" ) > Y = input("Second number:" ) > print X, "+", Y, "= ",X + Y > elif cal_opt == 2: > X = input("First number:" ) > Y = input("Second number:" ) > print X, "-", Y, "= ",X - Y > elif cal_opt == 3: > X = input("First number:" ) > Y = input("Second number:" ) > print X, "*", Y, "= ",X * Y > elif cal_opt == 4: > X = input("First number:" ) > Y = input("Second number:" ) > if Y == 0: > print "Division by zero ot allowed!" > Y = input("Second number:" ) > else: > print X, "/", Y, "= ",X / Y > elif cal_opt == 5: > X = input("First number:" ) > Y = input("Second number:" ) > if Y == 0: > print "Division by zero ot allowed!" > Y = input("Second number:" ) > else: > print X, "/", Y, "= ",X / Y," R ", X % Y > elif cal_opt == 6: > X = input("First number:" ) > Y = input("Power:" ) > print X, "**", Y, "= ",X**Y > elif cal_opt == 7: > X = input("Number to find the square root of:" ) > print "The square root of", X, " = ",X**0.5 > elif cal_opt == 9: ##############################<== here > break ###################################<= here > else: > print "That's not an option. Try again." > menu() > cal() > print "Goodbye" > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor