Session 3 You are looking ahead. This session opens once sessions 1 and 2 are finished; until then it is here to read. Today is session 1
Functions, and reading where code stops
In this session you run ten small programs and read what Python prints when one stops with an error: the file, the line, and why. A few finish without an error and print the wrong thing, which is harder to catch. Most use functions, so watch what goes into a function and what comes back out.
This page shows the session as it looks before you start. The trial keeps your progress in this browser: open a part and it picks up where you left it, and the board reads the same record.
Where this comes from
The skill and how hard it is come from those courses; this task was written here. Checked 2026-11-10.
Ten small programs are in a zip file. Run all ten and sort them into those two kinds. Most use functions, so watch what goes into a function and what comes back out.
Fetch ten-programs.zip, unzip it, and run every one of the ten. Put each in one of two piles: it stopped, or it finished and printed something wrong.
Uses: Python tutorial, “Errors and Exceptions” — sections 8.1 and 8.2 · the reference card on this page
Pick three that stopped. For each one: the file, the line number Python named, and one sentence on what the code assumed that was not true. Not how to fix it.
Uses: Python tutorial, “Errors and Exceptions” — sections 8.1 and 8.2 · MIT 6.100L, Lecture 8: Functions as Objects — the lecture-notes PDF, the scope half
Take 03_reassign.py and make it work by handing the new total back out of the function instead of assigning to the name outside it. Run it before and after.
Uses: MIT 6.100L, Lecture 7: Decomposition, Abstraction, Functions — the lecture-notes PDF · the reference card on this page
No clock on this card. The session is done when you can do the thing, whether that took forty minutes or three sittings.