A function can call itself! I.e., in the definition of a function, we can write a call to the function itself. This is a powerful idea that is seen throughout computer science and we will give you an introduction over a 2-lecture sequence. So be patient as you learn this new concept. Learn a little, digest the idea for a few days, and learn more next lecture.
AND read 5.8 - 5.10
Slides: individual slides for viewing , 6-up layout for printing
Examples:
factorial.py
,
playWithDolls.py
,
russian.py
(module to provide class
Doll
--you don't need to understand or even read the code),
blastoff.py
,
num_es.py
,
deblank.py
To download the above .py files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as".
This way
you
choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).