Print vs logging
The sonar contact lamp never lights. Find out why with print statements, fix it, then turn the prints into logging with levels, names and line numbers you can switch off without deleting a line.
Open it in the simulatorFind and fix real bugs in a deep sea probe's Python on a Raspberry Pi: tracebacks, print and logging, asserts, bisection, off-by-one errors and state bugs, then three broken scripts as the boss.
0 of 7 done
7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.
The sonar contact lamp never lights. Find out why with print statements, fix it, then turn the prints into logging with levels, names and line numbers you can switch off without deleting a line.
Open it in the simulatorThe sonar puts the sea floor at 21,579 m. Find the broken stage by halving the pipeline, then use the same halving to find one bad ping in a thousand and the first bad firmware version in sixteen.
Open it in the simulatorBugs that live in remembered values: a toggle that crashes on its first press, a default list shared by every dive, a backup that empties itself, and a deepest-point record that leaks from one dive into the next.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
Tracebacks, prints and logs: make the program tell you what went wrong.
The Nereus depth script crashes. Read a MicroPython traceback from the bottom up, fix a bad reading, a misspelled name and a missing key, and catch bad input without losing the traceback.
0 of 5 steps
The sonar contact lamp never lights. Find out why with print statements, fix it, then turn the prints into logging with levels, names and line numbers you can switch off without deleting a line.
0 of 5 steps
Asserts that catch a bug where it starts, and halving that finds it anywhere.
The ballast tank goes below empty without a word. Make the program check its own assumptions with assert, fix the bug the assert catches, and turn asserts into small tests that guard the fix.
0 of 5 steps
The sonar puts the sea floor at 21,579 m. Find the broken stage by halving the pipeline, then use the same halving to find one bad ping in a thousand and the first bad firmware version in sixteen.
0 of 5 steps
Off by one and remembered state: the two bugs every program meets.
The most common bug in programming, four ways: an index one past the end, a loop that skips the first reading, a zone boundary on the wrong side, and a fence post. Each found with the same checklist and lit on the traffic lights.
0 of 5 steps
Bugs that live in remembered values: a toggle that crashes on its first press, a default list shared by every dive, a backup that empties itself, and a deepest-point record that leaks from one dive into the next.
0 of 5 steps
Three broken scripts, one hour to the dive.
The boss: three of Nereus's scripts fail before a dive, a beacon that never flashes, a log summary that crashes on its first line and a mode button that dies on the third press. Find each bug with the right technique, fix it, and write the bug report.
0 of 7 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Debugging Python are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Print vs logging, Bisecting a bug and State bugs.
With "Reading a traceback", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.