Assignment 20 — function implementation

Due Monday, March 25


Module take_it_away.py


Function donut( d, h )

π2 ( d2 - h2 ) ( d - h ) / 32

The π in the above formula is pi. Remember the best estimate of π in Python is math.pi.

donut( 4.5, 1.75 ): 14.577906891257474:

donut( 3.75, 2.15 ): 4.658453277314178


Function signum( x )

f( -3.5 ): -1

f( 0 ) : 0

f( 5 ): 1



Function mid( s )

mid( 'abcdef' ): 'cd'

mid( 'abcde' ): 'c'