Python 5.5Code walkthrough8 parts

Debugging

Find a bug systematically.

In this lesson8 parts

  1. 01An answer that is wrong
  2. 02Reproduce it on the smallest input
  3. 03Print debugging
  4. 04A breakpoint
  5. 05The debugger in VS Code
  6. 06The fix, and keeping the input
  7. 07Where debugging misleads
  8. 08Recap, your challenge, and next

Key terms

The words this lesson introduces, each in one line. The module’s glossary collects them all.

breakpoint
The line where the debugger stops. breakpoint() in the code sets one; so does a click beside a line number in VS Code.
bug
Code that runs, and does something other than what it should.
debugger
A tool that stops a program so you can look at its values. Python's is pdb; VS Code has one built in.
reproduce
Make a bug happen on purpose, on an input you can give again.

Quiz 5 questions

Your first pick on each question is the one that counts, and a right one earns a coin. Getting one wrong here is how the lesson sticks.

Practice

Problems to solve in your own notebook. Each states the problem, not the steps: working out the steps is the exercise. Level A applies the lesson, B combines it with earlier ones, C stretches it.

Common mistakes

What you will see when it goes wrong, why it happens, and the fix.

Where it’s used

Where this lesson’s ideas turn up in real work.