Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. import math
  2. def Square():
  3. sqlength = int(input("What is the length of the square?: "))
  4. sqarea = str(round(sqlength*sqlength))
  5. print("The area of the square is", sqarea)
  6.  
  7. def Rectangle():
  8. rectlength = int(input("What is the length of the rectangle?: "))
  9. rectwidth = int(input("What is the width of the rectangle?: "))
  10. rectarea = str(round(rectlength*rectwidth))
  11. print("The area of the rectangle is", rectarea)
  12.  
  13. def Circle():
  14. circleradius = int(input("What is the radius of the circle?: "))
  15. circlearea = str(round(math.pi*circleradius** 2))
  16. print("The area of the circle is", circlearea)
  17.  
  18. def Prism():
  19. prismlength = int(input("What is the length of the rectangular prism?: "))
  20. prismwidth = int(input("What is the width of the rectangular prism?: "))
  21. prismheight = int(input("What is the height of the rectangular prism?: "))
  22. prismvolume = str(round(prismwidth*prismheight*prismlength))
  23. print("The volume of the rectangular prism is", prismvolume)
  24.  
  25. def Cylinder():
  26. cylradius = int(input("What is the radius of the cylinder?: "))
  27. cylheight = int(input("What is the height of the cylinder?: "))
  28. cylsurfacearea = str(round(2*math.pi*cylradius*cylheight+2*math.pi*cylradius**2))
  29. print("The surface area of the cylinder is", cylsurfacearea)
  30.  
  31. def Menu():
  32. print("1. Find the area of a square\n2. Find the area of a rectangle\n3. Find the area of a circle\n4. Find the volume of a rectangular prism\n5. Find the surface area of a cylinder\n6. Return to the Previous Menu")
  33. lastmenu = int(input("What would you like to do? Type in the number next to the menu option: "))
  34. if lastmenu == 1:
  35. Square()
  36. if lastmenu == 2:
  37. Rectangle()
  38. if lastmenu == 3:
  39. Circle()
  40. if lastmenu == 4:
  41. Prism()
  42. if lastmenu == 5:
  43. Cylinder()
  44. else:
  45. Main()
  46.  
  47. def Main():
  48. print("1. Use the Handy Toolkit\n2. View Instructions\n3. Exit Program")
  49. firstmenu = int(input("What would you like to do? Type in the number next to the menu option: "))
  50. if firstmenu == 1:
  51. Menu()
  52. if firstmenu == 2:
  53. print("You must only enter the numbers 1 to 6 and don't include units")
  54. Main()
  55.  
  56. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement