All pastes #962948 Raw Edit

Area

public python v1 · immutable
#962948 ·published 2008-03-30 03:24 UTC
rendered paste body
#This program calculates the perimete and area of a rectangledef print_options():    print " 'q' quit the program"    print " 'p' print options"    print " 's' find the area of a square"    print " 'r' find the area of a rectangle"    print " 'c' find the area of a circle"def area_square(s_area,s_height):    return s_width*s_heightdef area_rectangle(r_width,r_height):    return r_width*s_heightdef area_circle(radius):    return 3.14*radius**2choice = "p"while choice !="q":    if choice == "s":        s_width = input("Width: ")        s_height = input("Height: ")        print "Area:",area_square(s_width,s_height)    elif choice == "r":        r_height = input("Height: ")        r_width = input("Width: ")        print "Area:",area_rectangle(r_width,r_height)    elif choice == "c":        radius = input("Radius: ")        print "Area:",area_circle(radius)    elif choice != "q":        print_options()    choice = raw_input("option:")