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 = 3
for turn in range(1, 4):
total = total + 3
print(total)
turntotal
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.

Step 1 of 5Called right: 0 of 3

Computer Science · Debugging

What is a debugger, really?

You have just used a debugger to catch the doubling bug. Four people describe what a debugger does.

Which one is closest to what you think a debugger does?
How sure are you?

Computer Science · Debugging

Put a debugging session in order

the order the steps happen in a debugging session

1 · Happens first7 · Happens last
  1. Correct the faulty line

  2. The program pauses at the breakpoint

  3. Run it through the debugger again to check

  4. Set a breakpoint on a chosen line

  5. Spot where the watch differs from what should happen

  6. Run the program in the debugger

  7. Step one statement at a time, watching the variables

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.

Python
  1. total = 3
  2. for turn in range(1, 4):
  3. total = total + 3
  4. print(total)

The output of every version was checked by running it in Python.

Computer Science · Debugging

Explain it in your own words

Explain how a debugger helps a programmer to find and fix a fault in a program. [6 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1Pause, step, watch, compare: the first step where the watch and the plan disagree points at the fault.
2A debugger runs the program under your control. It does not find or fix the bug for you.
3Observing the run is quicker and easier than finding a fault by reading the code alone.
4After you correct the fault, run the program through the debugger again to confirm it behaves as intended.

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?
A software development tool, usually part of an IDE, that helps a programmer find and fix faults (bugs) in a program.
What does IDE stand for?
Integrated development environment. A debugger is usually provided as part of one.
How does a debugger change the way a program runs?
The program runs in a controlled way: the programmer decides when it runs, pauses and continues, instead of it simply running start to finish.
What is a breakpoint?
A line of code the programmer chooses. When the running program reaches it, the program pauses.
What is stepping?
Executing the paused program one statement at a time.
What does "continue" do?
It lets the paused program carry on running.
What is a variable watch?
Watching the current values of variables as they change while you step through the program.
What can you examine while the program is paused?
The line the program has reached and the current values of its variables.
How does a debugger help you spot a fault?
You compare what the program actually does with what it is meant to do. The first mismatch shows where its behaviour goes wrong.
Why is a debugger quicker than reading the code alone?
You observe the program as it runs and can locate where its behaviour goes wrong, instead of working it out from the text.
What should you do after correcting a fault?
Run the program through the debugger again to confirm it now behaves as intended.

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 posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

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.