GCSE · Computer Science · Eduqas · Spec C500QS
Debugger
Your program runs with no error, but gives the wrong answer, and staring at the code is not helping. What if you could freeze it mid-run and watch it think?
Computer Science · Debugging
Watch the program think
Pause it, step it, and call each value before the watch shows it.
This game should DOUBLE your points on every turn, for 3 turns, starting on 3 points. The programmer has put a breakpoint on the first line, so the debugger has paused the run there. Press Next to step: the debugger runs ONE statement, then pauses again. The table is your variable watch, showing what each variable holds right now. At the marked steps, call the value before the watch shows it. Nothing is really run here: every value is written by the lesson.
total = 3for turn in range(1, 4):total = total + 3print(total)
| turn | total |
|---|---|
| 3 |
Step 1. Paused at the breakpoint, then stepped once: total = 3 has run, so the watch shows total is 3. This first step is worked for you.
Computer Science · Debugging
Fix it, then run it again
The doubling game from the debugger ran without any error message but printed the wrong answer, and the programmer wanted it to print 24. Choose a fix for the flagged line, press Run, and check the output against 24.
- total = 3
- for turn in range(1, 4):
- total = total + 3
- print(total)
The output of every version was checked by running it in Python.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Pause a running program, step through it, and catch the bug in the act.
What you need to know
- A debugger is a software tool, usually part of an IDE, that helps a programmer find and fix faults (bugs).
- It does not find or fix bugs for you. It runs the program under your control, and you do the finding.
- Instead of running start to finish, the program runs in a controlled way: you decide when it runs, pauses and continues.
Have a goA program normally runs start to finish without you. Under a debugger, what three things do you get to decide?
When it runs, when it pauses, and when it continues.
A normal run gives you no say once it starts. Under a debugger you control when each of those three things happens.
- A breakpoint is a line of code you choose. When the running program reaches it, the program pauses.
- From the pause you can continue the program, or step: execute it one statement at a time.
Have a goYour mate bets that a breakpoint on line 4 "ends the program at line 4". Do they win the bet? Say what really happens.
No. The program pauses when it reaches line 4, and you can then continue it or step one statement at a time.
A breakpoint pauses the run, it does not end it. That is why continuing and stepping are possible at all.
- While it is paused, you can examine the program's state: the line it has reached and the current values of its variables.
- Watching a variable's value change as you step is called a variable watch.
Have a goA paused program is about to run count = count + 2, and count holds 4. You step once. What does the variable watch show for count?
6
Stepping runs that one statement and then pauses. The watch shows the value after it ran, not the old 4.
- Compare what the program actually does with what it is meant to do. The first mismatch shows where it goes wrong.
- Observing the program as it runs makes a fault quicker and easier to find and correct than reading the code alone.
- After correcting the fault, run the program through the debugger again to confirm it now behaves as intended.
The big picture
A debugger is a software tool, usually part of an IDE, that runs your program under your control. A breakpoint pauses it on a line you choose, and from there you can continue or step one statement at a time while watching the variables. The first step where the watch disagrees with what should happen points at the fault. Once you have corrected it, run the program through the debugger again to confirm it behaves as intended.
Key points
Worked example
Problem
This program should take 1 life off for each of 2 hits, starting from 3 lives, so it should print 1. It prints -1. lives = 3 for hit in range(1, 3): lives = lives - 2 print(lives) Use a debugger session to find the fault.
⚠ Watch out
Thinking the debugger finds and fixes the bug for you. It only runs the program under your control. You spot the fault by comparing what the watch shows with what the program is meant to do, then you correct it, then you run it again to check.
Memory hook
Pause it, Step it, Watch it, Compare it, Re-run it. Five moves, in that order, every time.
Check yourself
A program should print 25 but prints 15. Say what you would set a breakpoint on, what you would watch as you step, and how you would know you had found the fault.
Flashcards
(11)What is a debugger?
What does IDE stand for?
How does a debugger change the way a program runs?
What is a breakpoint?
What is stepping?
What does "continue" do?
What is a variable watch?
What can you examine while the program is paused?
How does a debugger help you spot a fault?
Why is a debugger quicker than reading the code alone?
What should you do after correcting a fault?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Eduqas GCSE Computer Science topics
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 15 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.