Question

# Write functions - def sphereVolume(r) - def sphereSurface(r) - def cylinderVolume(r, h) - def cylinderSurface(r, h) - def coneVolume(r, h) - def coneSurface(r, h) that compute the volume and surface area of a sphere with a radius r, a cylinder with a circular base with radius r and height h, and a cone with a circular base with radius r and height h. Place them into a geometry module. Then write a program that prompts the user for the values of r and h, calls the six functions, and prints the results.

Solution

Verified
Step 1
1 of 3
# geometry.py

from math import pi, sqrt

class Geometry:
def sphereVolume(r):
return 4/3 * pi * r**3

def sphereSurface(r):
return 4 * pi * r**2

def cylinderVolume(r, h):
return r**2 * pi * h

def cylinderSurface(r, h):
return 2 * r**2 * pi + r**2 * pi * h

def coneVolume(r, h):
return 1/3 * pi * r**2 * h

def coneSurface(r, h):
return pi * r**2 + pi * r * sqrt(h**2 + r**2)


## Recommended textbook solutions #### Computer Organization and Design MIPS Edition: The Hardware/Software Interface

5th EditionISBN: 9780124077263 (7 more)David A. Patterson, John L. Hennessy
220 solutions #### Fundamentals of Database Systems

7th EditionISBN: 9780133970777 (2 more)Ramez Elmasri, Shamkant B. Navathe
687 solutions #### Introduction to Algorithms

3rd EditionISBN: 9780262033848 (3 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
726 solutions #### Python for Everyone

2nd EditionISBN: 9781119056553 (2 more)Cay S. Horstmann, Rance D. Necaise
730 solutions