Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import math
  2. class Geometry():
  3. def __init__(self,r,h):
  4. self._radius=r
  5. self._height=h
  6. self._sphereVolume=0
  7. self._sphereSurface=0
  8. self._cylinderVolume=0
  9. self._cylinderSurface=0
  10. self._coneVolume=0
  11. self._coneSurface=0
  12. def sphereVolume(self):
  13. self._sphereVolume=self._sphereVolume+(4/3)*math.pi*(self._radius**3)
  14. return self._sphereVolume
  15. def sphereSurface(self):
  16. self._sphereSurface=self._sphereSurface+4*math.pi*(self._radius**2)
  17. return self._sphereSurface
  18. def cylinderVolume(self):
  19. self._cylinderVolume=self._cylinderVolume+math.pi*(self._radius**2)*self._height
  20. return self._cylinderVolume
  21. def cylinderSurface(self):
  22. self._cylinderSurface=self._cylinderSurface+2*math.pi*(self._radius**2)+2*math.pi*self._radius*self._height
  23. return self._cylinderSurface
  24. def coneVolume(self):
  25. self._coneVolume=self._coneVolume+math.pi*(self._radius**2)*self._height/3
  26. return self._coneVolume
  27. def coneSurface(self):
  28. self._coneSurface=self._coneSurface+math.pi*self._radius*(self._radius+(self._height**2+self._radius**2)**0.5)
  29. return self._coneSurface
  30. bob=Geometry(5,5)
  31. print(bob.sphereVolume())
  32. print(bob.sphereSurface())
  33. print(bob.cylinderVolume())
  34. print(bob.cylinderSurface())
  35. print(bob.coneVolume())
  36. print(bob.coneSurface())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement