Advertisement
Guest User

Untitled

a guest
May 8th, 2012
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. # P2PU - Python - Chapter 4 - Operators
  4. # Calculate surface area and volume of a sphere based on a given radius
  5.  
  6. import math
  7.  
  8. try:
  9.         radius = raw_input('Radius: ')
  10.         radius = float(radius)
  11. except:
  12.         print 'You must enter a number!'
  13.         exit()
  14.  
  15. area = 4 * math.pi * math.pow(radius, 2)
  16. vol  = 4.0 / 3 * math.pi * math.pow(radius, 3)
  17.  
  18. print 'Area:', area
  19. print 'Volume:', vol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement