Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. #!/usr/local/bin/python
  2.  
  3. #do imports- blah blah
  4. import string, sys
  5.  
  6. #-----------------------------
  7. # define some shape functions
  8. #-----------------------------
  9.  
  10. #routine for dealing with circles
  11. def collectCircle():
  12.     circle_diameter = raw_input("Enter the diameter of the circle: ")
  13.    
  14.     #ask the rest of your questions here
  15.    
  16.     #once you have all your input for this shape, do your calculations
  17.    
  18.     #now print out any information for this shape
  19.    
  20.     return
  21.  
  22. #routine for dealing with squares
  23. def collectSquare():
  24.     square_size = raw_input("Enter a number for the height and width of the square: ")
  25.    
  26.     square_area = square_size * square_size
  27.     print "the area of your square is: %d" % square_area
  28.    
  29.     square_perim = square_size * 4
  30.     print "the perimeter of your square is: %d" % square_perim
  31.    
  32.     return
  33.  
  34. #routine for dealing with rectangles
  35. def collectRectangle():
  36.     rectangle_height = raw_input("Enter the height of the rectangle: ")
  37.     rectangle_width = raw_input("Enter the width of the rectangle: ")
  38.    
  39.     #ask the rest of your questions here
  40.    
  41.     #once you have all your input for this shape, do your calculations
  42.    
  43.     #now print out any information for this shape
  44.    
  45.     return
  46.  
  47. #------------------------------
  48. # start the main script
  49. #------------------------------
  50.  
  51. # get the user's shape selection
  52. # the shape selection will be a number
  53. shape_selection = raw_input("Please select a shape: ")
  54.  
  55. #which shape did we get?
  56. if shape_selection == 1:
  57.     collectCircle()
  58.    
  59. elif shape_selection == 2:
  60.     collectSquare()
  61.    
  62. elif shape_selection == 3:
  63.     collectRectangle()
  64.    
  65. else:
  66.     print "ERROR: Unrecognized shape."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement