Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sphere():
- import math
- radius = float(input('Please enter the radius of the circle: '))
- if radius < 0:
- print ('Do not enter 0 or lower')
- else:
- volume = 4/3*math.pi*radius*radius*radius
- return radius, volume
- def triangle():
- base = float(input('What is the base of the triangle? '))
- height = float(input('What is the height of the triangle? '))
- return base, height
- def squares():
- import math
- for odds in range(1,50,2):
- return odds
- def main():
- print('1. Calculate the volume of a sphere')
- print('2. Calculate the Area of a Triangle')
- print('3. Show odds and their squares between 1-50')
- print('4. Quit')
- menu()
- def menu():
- option = int(input('Please choose an option from the menu: '))
- while option != 4:
- print('1. Calculate the volume of a sphere')
- print('2. Calculate the Area of a Triangle')
- print('3. Show odds and their squares between 1-50')
- print('4. Quit')
- option = int(input('Please choose an option from the menu: '))
- if option == 1:
- sphere()
- print('Radius:', format(option,'10.2f'))
- print('Volume:', format(option,'10.2f'))
- elif option == 2:
- triangle()
- area = option * option * .5
- print('Height:', format(option,'15.2f'))
- print('Base:', format(option,'15.2f'))
- print('Triangle Area:', format(area,'15.2f'))
- elif option == 3:
- import math
- squares()
- root = math.sqrt(option)
- print(option, '\t', root)
- elif option == 4:
- print('Thank you for using this program')
- break
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement