Advertisement
los1234

Here!!!

Feb 23rd, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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(base, height):
  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 = base * height * .5
  42. print('Height:', format(height,'15.2f'))
  43. print('Base:', format(base,'15.2f'))
  44. print('Triangle Area:', format(area,'15.2f'))
  45. elif option == 3:
  46. squares()
  47. root == math.sqrt(odds)
  48. print(odds, '\t', root)
  49. elif option == 4:
  50. print('Thank you for using this program')
  51. break
  52.  
  53. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement