a trial — your progress is kept in this browser only

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.

Why this one is hereYou run ten programs of the kind an agent hands you. When one stops with an error, Python names the file and the line; when one finishes with a wrong answer, nothing warns you. A1 ends with that second kind: a script that prints Success on every run while the week’s total is 12% off.
Read this first115 min · the material itself, not my summary of it
MIT 6.100L, Lecture 7: Decomposition, Abstraction, Functions — the lecture-notes PDF what a function is, its arguments, and what return hands back45 min
MIT 6.100L, Lecture 8: Functions as Objects — the lecture-notes PDF, the scope half what a name inside a function can and cannot reach, and what a function hands back when it has no return20 min
Python tutorial, “Errors and Exceptions” — sections 8.1 and 8.2 how to read what Python prints when it stops15 min
MIT 6.100L, Lecture 5: Floats and Approximation Methods — the lecture-notes PDF, the floats half why adding 0.1 ten times does not reach 1, and why floats are never compared with ==20 min
MIT 6.100L — Finger Exercise, Lecture 7 writing a function that returns, and one that only prints15 min
This session has three parts
1No-help check17 min
2Ten small programs: read where each one stopsthe lab · below
3Talk through someone else’s codeinterview · 25 min
The lab · three things, stop anywhere
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.

AI may explain, never write or debug.stuck 15 min is normal
1
Run the ten, and sort them into two piles

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

2
Name the line and the wrong assumption, for three of them

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

3
Fix one of them with return

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.