Please send questions to
st10@humboldt.edu .
#-----
# contract : circle_area : number -> number
# purpose: determine the area of a circular disk
# whose radius is <radius>
# example: abs (circle_area(5) - 78.53975 ) < .001
#-----
PI = 3.14159
from math import *
def circle_area(radius):
return PI * pow(radius, 2)
#-----
# contract : ring_area : number number -> number
# purpose: determine the area of a ring whose outer
# radius is <outer> and whose "hole"
# has radius <inner>
# example: abs (ring_area(10, 5) - 235.61925 ) < .001
#-----
def ring_area(outer, inner):
outer_area = circle_area(outer)
hole_area = circle_area(inner)
return outer_area - hole_area
#-----
# contract: name_in_lights: anything -> void
# purpose: print <thing> between two lines of 20 asterisks
# example: name_in_lights(13) would cause the following
# to be printed to the screen (ignoring the comment marks!):
# ********************
# 13
# ********************
def name_in_lights(thing):
print "********************"
print thing
print "********************"
name_in_lights(13)
#-----
# contract: greet_rain: void -> void
# purpose: greet the rain, printig to the screen
# example: if you call greet_rain(), the following
# should be printed to the screen:
# hello, rain!
def greet_rain():
print "hello, rain!"
#-----
# contract: show_name : void -> void
# purpose: asks the user for his/her name, and then prints it
# between two rows of 20 asterisks
# example: if I call show_name(), I will see a prompt:
#
# type your name:
#
# ...if I then type George, the following will be printed
# to the screen:
#
# ********************
# George
# ********************
def show_name():
name = raw_input("type your name:")
name_in_lights(name)