Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python
- #do imports- blah blah
- import string, sys
- #-----------------------------
- # define some shape functions
- #-----------------------------
- #routine for dealing with circles
- def collectCircle():
- circle_diameter = raw_input("Enter the diameter of the circle: ")
- #ask the rest of your questions here
- #once you have all your input for this shape, do your calculations
- #now print out any information for this shape
- return
- #routine for dealing with squares
- def collectSquare():
- square_size = raw_input("Enter a number for the height and width of the square: ")
- square_area = square_size * square_size
- print "the area of your square is: %d" % square_area
- square_perim = square_size * 4
- print "the perimeter of your square is: %d" % square_perim
- return
- #routine for dealing with rectangles
- def collectRectangle():
- rectangle_height = raw_input("Enter the height of the rectangle: ")
- rectangle_width = raw_input("Enter the width of the rectangle: ")
- #ask the rest of your questions here
- #once you have all your input for this shape, do your calculations
- #now print out any information for this shape
- return
- #------------------------------
- # start the main script
- #------------------------------
- # get the user's shape selection
- # the shape selection will be a number
- shape_selection = raw_input("Please select a shape: ")
- #which shape did we get?
- if shape_selection == 1:
- collectCircle()
- elif shape_selection == 2:
- collectSquare()
- elif shape_selection == 3:
- collectRectangle()
- else:
- print "ERROR: Unrecognized shape."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement