#!/usr/bin/env python3 """ PROBLEM: Chapter 6, Programming Exercise #3 Write definitions for these functions: sphereArea(radius) Returns the surface area of a sphere having the given radius. sphereVolume(radius) Returns the volume of a sphere having the given radius. Use your functions to get the surface area and volume of a sphere of a given radius. """ """ PSEUDOCODE: # define a sphereArea function that takes a parameter radius and returns the surface area # of a sphere # define a sphereVolume function that takes a parameter radius and returns the volume # of a sphere # define a "main" function # get a radius from the user # call the sphereArea function with that radius and print result # call the sphereVolume function with that radius and print result # if __name__ == "__main__": # main() """ """ ch06ex03.py, from Zelle, Python Programming Use functions sphereArea and sphereVolume to calculate values. @author Richard White @version 2014-05-28 """ def sphereArea(radius): """Returns the surface area of a sphere having the given radius""" return 4 * 3.141592654 * radius**2 def sphereVolume(radius): """Returns the volume of a sphere having the given radius""" return 4 / 3 * 3.141592654 * radius**3 def main(): r = eval(input("Enter the radius of a sphere: ")) print("The area of that sphere is",sphereArea(r)) print("and the volume of that sphere is",sphereVolume(r)) if __name__ == "__main__": main()