Advertisement
Guest User

Spheres

a guest
Jan 18th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from math import pi
  2.  
  3. def sphereFunctions():
  4.     radius = (input("Radius: "))
  5.     try:
  6.         radius = float(radius)
  7.         if radius >= 0.0:
  8.             print("The diameter is",radius*2)
  9.             print("The circumference is",radius*2*pi)
  10.             print("The surface area is",radius**2*pi*4)
  11.             print("The volume is:",radius**3*pi*(4/3))
  12.             print("Enter another positive value, or a negative value to exit.")
  13.             sphereFunctions()
  14.         else:
  15.             print("You entered a negative number. Goodbye!")
  16.     except ValueError:
  17.         print("You may only enter numbers.")
  18.  
  19. sphereFunctions()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement