SLIDE 31 Conditionals More on Functions Recursion Typing Call stack and Scope More on Parameters Program Design
Traceback
✞
def p r i n t t w i c e ( bruce ) : print bruce , bruce print cat # notice cat has not been defined . def cat twice ( part1 , part2 ) : cat = part1 + part2 p r i n t t w i c e ( cat ) chant1 = ” Python i s great . ” chant2 = ” Python i s fun . ” cat twice ( chant1 , chant2 )
✡ ✝ ✆ ✞
Traceback ( innermost l a s t ) : F i l e ” t e s t . py ” , l i n e 11 , in <module> cat twice ( chant1 , chant2 ) F i l e ” t e s t . py ” , l i n e 7 , in cat twice p r i n t t w i c e ( cat ) F i l e ” t e s t . py ” , l i n e 3 , in p r i n t t w i c e print cat NameError : global name ’ cat ’ is not defined
✡ ✝ ✆
Lecture D.2. (MDV) Programming I Academic Year 2012-2013 29 / 60