Advertisement
los1234

Idk!

Feb 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. def sphere():
  2. import math
  3. radius = float(input('Please enter the radius of the circle: '))
  4. if radius < 0:
  5. print ('Do not enter 0 or lower')
  6. else:
  7. volume = 4/3*math.pi*radius*radius*radius
  8. return radius, volume
  9.  
  10. def triangle():
  11. base = float(input('What is the base of the triangle? '))
  12. height = float(input('What is the height of the triangle? '))
  13. return base, height
  14.  
  15. def squares():
  16. import math
  17. for odds in range(1,50,2):
  18. return odds
  19.  
  20. def main():
  21. print('1. Calculate the volume of a sphere')
  22. print('2. Calculate the Area of a Triangle')
  23. print('3. Show odds and their squares between 1-50')
  24. print('4. Quit')
  25. menu()
  26.  
  27. def menu():
  28. option = int(input('Please choose an option from the menu: '))
  29. while option != 4:
  30. print('1. Calculate the volume of a sphere')
  31. print('2. Calculate the Area of a Triangle')
  32. print('3. Show odds and their squares between 1-50')
  33. print('4. Quit')
  34. option = int(input('Please choose an option from the menu: '))
  35. if option == 1:
  36. sphere()
  37. print('Radius:', format(option,'10.2f'))
  38. print('Volume:', format(option,'10.2f'))
  39. elif option == 2:
  40. triangle()
  41. area = option * option * .5
  42. print('Height:', format(option,'15.2f'))
  43. print('Base:', format(option,'15.2f'))
  44. print('Triangle Area:', format(area,'15.2f'))
  45. elif option == 3:
  46. import math
  47. squares()
  48. root = math.sqrt(option)
  49. print(option, '\t', root)
  50. elif option == 4:
  51. print('Thank you for using this program')
  52. break
  53.  
  54. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement