Source code for area_solid

"""
Returns the area of a rectangular solid by finding the area of all three
of its surfaces. This module is used to illustrate the use of functions and
how functions call other functions.

Example use of these functions::

   >>> print area_solid(1,1,1)
   >>> print area_solid(2,3,4)
   >>> a = area_solid(1,1,1)
   >>> print "Area is", a

"""

[docs]def area_rectangle( length, width): """Returns the area of a rectangle given length and width. """ return length * width
[docs]def area_solid( length, width, height): """Returns the area of a rectangular solid given length, width and height by finding and adding the area of its six different rectangular surfaces. """ surface_area = 2*area_rectangle(length,width) surface_area += 2*area_rectangle(length,width) surface_area += 2*area_rectangle(width,height) return surface_area