We continue our discussion on recursion, getting into more details:
You can use Python Tutor, but do not just watch Python Tutor work passively. You need to predict how Python will execute the next statement before you click forward on Python Tutor. It's ok if your prediction isn't perfect right now; you just need to really try it for yourself to think through the process. We will do more during lecture to build your understanding of recursion.
Slides: individual slides for viewing, 6-up layout for printing
[After lecture...] Here are all the slides, including the progression of the call stack for executing
factorial(3), the answers to the clicker questions, and the completed function
isPalindrome: individual slides for viewing, 6-up layout for printing
factorial.py (from previous lecture),
person.py (module to provide
Person instances--you don't need to understand or even read person.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).
Answer to optional practice question: The final lecture slide lists an optional practice question
all_ancestors related to the lecture example
num_ancestors. Implement it yourself in this incomplete module family.py (same skeleton file as that posted above). After you have implemented it, you can take a look at our solution.