Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # P2PU - Python - Chapter 4 - Operators
- # Calculate surface area and volume of a sphere based on a given radius
- import math
- try:
- radius = raw_input('Radius: ')
- radius = float(radius)
- except:
- print 'You must enter a number!'
- exit()
- area = 4 * math.pi * math.pow(radius, 2)
- vol = 4.0 / 3 * math.pi * math.pow(radius, 3)
- print 'Area:', area
- print 'Volume:', vol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement