|
this one better?
[HTML]
#By Snipertomcat
#Area Calculator w/ menu interface
print "Welcome to Area-Calc."
def menu_options(): #Getting all the def's squared away
print "Options:"
print " 'p' print options"
print " 'r' calculate area of a rectangle "
print " 's' calculate area of a square "
print " 'c' calculate area of a circle "
print " 'q' quit the program"
def area_rec(width,height):
return width * height
def area_square(num):
return num * num
import math
def area_circle(radius):
return math.pi * radius ** 2
menu_options() #Program starts here
def main():
choice = "p"
while choice != "q":
if choice == "r":
w = input("Rectangle width: ")
h = input("Rectangle hight: ")
print "The area is: ",area_rec(w,h)
elif choice == "s":
squarenum = input("Square length: ")
print "The area is: ", area_square(squarenum)
elif choice == "c":
rad = input("Radius: ")
print "The area is: ", area_circle(rad)
elif choice == "p":
menu_options()
choice = raw_input("Option: ")
main()
[/HTML]
|