Old Code working FINE
Expand|Select|Wrap|Line Numbers
- from math import *
- def menu():
- global menuSel
- print "\nSlect one of the following:"
- print "1. Calculate Area of Rectangle"
- print "2. Calculate Area of Circle"
- print "3. Quit"
- menuSel=input("Please enter your selection: ")
- while menuSel!=1 and menuSel!=2 and menuSel!=3:
- menuSel=input("Please re-enter a valid selection of 1, 2, or 3: ")
- return
- def rectangle():
- print "You have chosen a rectangle."
- b=input("enter base : ")
- h=input("enter height:")
- print "The area is ", b*h
- return
- def circle():
- print "You have chosen a circle."
- r=input("enter radius: ")
- print "The area is ",pi*r**2
- return
- def main():
- menu()
- while menuSel!=3:
- if menuSel==1:
- rectangle()
- elif menuSel==2:
- circle()
- menu()
- return
- main()
- raw_input("\nPress enter to exit.")
Expand|Select|Wrap|Line Numbers
- from math import *
- def menu():
- print "\nSlect one of the following:"
- print "1. Calculate Area of Rectangle"
- print "2. Calculate Area of Circle"
- print "3. Quit"
- menuSel=input("Please enter your selection: ")
- while menuSel!=1 and menuSel!=2 and menuSel!=3:
- menuSel=input("Please re-enter a valid selection of 1, 2, or 3: ")
- return
- def rectangle():
- print "You have chosen a rectangle."
- b=input("enter base : ")
- h=input("enter height:")
- print "The area is ", b*h
- return
- def circle():
- print "You have chosen a circle."
- r=input("enter radius: ")
- print "The area is ",pi*r**2
- return
- def main():
- choice = menu()
- while choice!=3:
- if choice==1:
- rectangle()
- elif choice==2:
- circle()
- choice =menu()
- return
- main()
- raw_input("\nPress enter to exit.")