Class 30 — Wednesday, November 3
Life is surprising
We are one people — Looking out for each other — Which means masking up
Look both ways
Agenda
- Live and learn
- Functions are first class in Python
- Chrestomathics
Downloads
- Module cookie.py
- Module translate.py
To do
- Complete homework 24
What is first class
- Consider module
cookie.py
def black() :
print( "Black" )
def white() :
print( "White" )
def go( f ) :
""" Invokes the function indicated by parameter f
"""
f()
if ( __name__ == "__main__" ) :
go( black ) # go() run's function black()
go( print ) # go() run's function print()
go( white ) # go() run's function white()
- Program run
Black
White
Problem at 손 (hand)
- Module translate.py to support text translation.
- Defines three functions
def word( string, dictionary = DEFAULT_DICTIONARY) :
# translate the word represented by string according to dictionary
...
line( text, dictionary = DEFAULT_DICTIONARY ) :
# translate the series of words represented by text according to dictionary
...
passage( text, dictionary = DEFAULT_DICTIONARY) :
# translate the series of lines represented by text according to dictionary
...
- Some sample translation text phrases
links
est la baguette fraiche
dubailte dubailte kesusahan und guaio
umlilo adolebitque und ketel bombolla
umucu di una pantanoso neidr
dans der ketel bouyi und cuire
oog di tritons und kaki di rano
yun di fledermoyz und lingua di chien
viperae foarke und blyn cuc stik
moo fotur und ovlet tis
pre eng viehatys di voimakas guaio
mag un inferno salda bouyi und bombolla
1112 artistry