Skip to contentVarnook
All courses
PythonIntermediate

Debugging in Python

Diagnose and repair small Python programs, preserving behaviour across normal, empty and boundary inputs with the standard library.

Recommended first: Intermediate Python. This course builds on it, but you can open it now.

Free to browse. You sign in at the first lesson so your progress is saved.

Free includes 3 learning hours each week, across all courses. If you use them up, running code pauses until Monday at 00:00 UK time; you can still read lessons and edit your code. Longer courses can be spread over several weeks. How weekly limits work.

About this course

Python 3.12.7 in your browser

Runs through Pyodide 0.27.2, with the Python standard library.

Maintained by Soulstack

Course overview reviewed
Exercise checks verified

Overview review covers the course summary, stated outcomes and final exercise example. Automated verification ran all 10 reference solutions against their checks and confirmed that starter code does not already pass. This is internal verification.

How exercise checks work

What you will be able to do

  • Reproduce faults and use tracebacks to locate their cause
  • Define missing-data, threshold and shared-state contracts
  • Refactor and extend small programs without losing prior behaviour
  • Transfer diagnosis to fresh event and sensor records

Put it into practice

What you will make

A repaired sensor peak report

The independent repair returns the first valid highest reading, including zero. The supplied data returns the lab reading at 0.

Output from the completed course exercise, using its supplied practice data. From Transfer to an unseen dataset and defect class.

('lab', 0)

Take a look inside

From the first lesson: Reproduce a wrong total. Read an example before starting the exercise yourself.

A collection fundraiser reports only its last donation. Reproduce the problem before editing: write down each expected contribution and their sum. Trace where the running value changes. A repair must preserve the result for one donation as well as several.

You read the explanation, edit the code and run the exercise checks. Your progress is saved after you sign in.

example.py
walked = 0for distance in [3, 5]:    walked += distanceprint(walked)  # 8

Syllabus

4 modules and 10 lessons. Each lesson is a short read followed by one exercise with checks.

Before you start

Some experience from Intermediate Python is recommended. Times are estimates; practise at your own pace. Every exercise has checks against its brief.

Read how checks, hints and saved work behave. If something is unclear, report a problem with this course and include the lesson link.