Eight functions from the barangay’s work, each with one mistake in it, the kind everyone makes: a number that is still text, a record without the key you asked for, a list changed behind the caller’s back, a total that starts again inside its loop, conditions in the wrong order, a loop that answers after one household, a range that stops one short, and a condition that leaves out its edge. Each check starts red: that is the point.
For each one you predict what the function gives, run it, trace the line that makes the difference (reading an error from the bottom up, printing inside a loop, following a value through the conditions by hand), fix it, and say in one sentence what the mistake was. Only two of the eight stop with an error; the others give a wrong answer quietly, and the last gives the right one on the barangay’s own records, so that only its check finds it. The companion has each fix and why it works.
Its notebooks
Section titled “Its notebooks”- 35_debugging_drill.ipynbDebugging drill: values, records and loopsRead itCompanion · 8 exercises
The notebooks are in your course folder; here you can read them without running anything.