Advertisement
Guest User

Cone volume and surface

a guest
May 11th, 2012
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Andres Kwan
  3.  
  4. import math
  5.  
  6. try:
  7.     r  = float(raw_input('radius\n'))
  8.     s  = float(raw_input('lateral height\n'))
  9. except:
  10.     print 'Enter a number!'
  11.     exit()
  12.  
  13. cone_surface   = math.pi * r * s + math.pi * r ** 2
  14. base_area      = math.pi * (r ** 2)
  15. cone_hight     = math.sqrt(s ** 2 - r ** 2 )
  16. cone_volume    = 1.0/3.0 * base_area * cone_hight
  17. #print 'surface of the cone: ' + str(surface)
  18.  
  19. print 'surface of the cone: ', cone_surface
  20. print 'base_area: ', base_area
  21. print 'cone_hight: ', cone_hight
  22. print 'volume of the cone: ', cone_volume
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement