Python 5.5The video for this lesson is on its way.
Everything else is ready: study the parts, the key terms and the quiz below.
Python 5.5Code walkthrough8 parts
Debugging
Find a bug systematically.
Loading your progress…Next: 5.6 Testing with assert and pytest
In this lesson8 parts
- 01An answer that is wrong
- 02Reproduce it on the smallest input
- 03Print debugging
- 04A breakpoint
- 05The debugger in VS Code
- 06The fix, and keeping the input
- 07Where debugging misleads
- 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.