GCSE · Computer Science · Eduqas · Spec C500QS
Run-time / execution errors
You press Run. Python reads your program and has no complaints. The first lines work perfectly. Then it crashes. Nobody broke a rule, so what went wrong?
Computer Science · Run-time errors
Press Run, then find the fault
This program works out an average. Python, the translator, accepts every line of it. Press Run and watch what happens. Then pick a fix for the line marked FIX and run it again.
- total = 20 # the scores added up
- count = 0 # how many scores were entered
- print("Working out the average...")
- result = total / count
- print("Average:", result)
The messages are the ones Python 3.13 gives for this exact code. Other languages word them differently.
Computer Science · Dry run
Same program, two runs
Call the outcome of line 3 before you see it.
Pick a run, then press Next. At the marked step, make your call before the screen shows it.
points = 60players = int(input("How many players? "))print("Sharing out the points...")print("Each player gets", points / players)
Variables
Step 1. points holds 60.
Think about what line 3 has to do with the value players holds.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Code that follows every rule, runs for a while, then crashes anyway.
What you need to know
- A run-time error (also called an execution error) is a kind of programming error.
- It only shows up while the program is running, not when the code is written or translated.
Have a goYour friend says: 'I pressed Run and Python didn't complain, so my program definitely has no errors.' Which kind of error could still be hiding, and when would it show?
A run-time error. It could show up later, while the program is running.
Translating the code only checks it against the language's rules. A run-time error only shows up during the run itself.
- The code obeys the rules of the language, so the translator accepts it and the program can start running.
- When it happens, the program may stop unexpectedly or crash.
- Example: result = total / count is valid code, but if count holds 0 when it runs, the division cannot be carried out.
Have a goresult = total / count. First total is 12 and count is 3: what does result hold? Then count is 0: what happens?
result holds 4 (Python shows 4.0). With count at 0, the division cannot be carried out, so the program may crash.
It is the same line both times. Only the value count holds decides whether it can be carried out.
- Whether it happens depends on the values in use, so one program can work with some inputs and fail with others.
- So don't hunt for a broken rule. Look at the values the faulty line meets.
Have a goLine 7 of a program crashes and the line is valid code. Do you first check the line for a broken rule, or check what values it met? Pick one.
Check what values the line met.
A broken-rule search finds nothing, because a run-time error is not a broken rule. The fault is in the value meeting the instruction.
- A program that was translated fine, or worked once, can still have a run-time error.
The big picture
A run-time (execution) error is a programming error that only shows up while a program is running. The code obeys the language's rules, so it is translated and can start. Then a value, such as a divisor of 0, makes an instruction impossible and the program may stop or crash. Whether it happens can depend on the input.
Key points
Worked example
Problem
A program prints "Sharing sweets..." and then stops on the line each = sweets / children, with the message ZeroDivisionError: division by zero. A classmate says, "There must be a typo on that line." Work out what has really happened.
⚠ Watch out
Thinking a program has no errors because the translator accepted it, or because it worked once. A run-time error is valid code, so it only shows up when the program runs with the wrong value.
Memory hook
The rules are checked before it runs, but the values only turn up while it runs.
Check yourself
Quick check: your program gives the right answer on its first test. Is that enough to say it has no run-time error? Explain why, or why not.
Flashcards
(8)What is another name for a run-time error?
What is a run-time error?
Can a program with a run-time error be translated and started?
What may happen when a run-time error occurs?
Why is result = total / count a run-time error risk when count holds 0?
Why can the same program work with some inputs and fail with others?
"The translator accepted my program, so it has no errors." True or false?
A line crashes, but its code is valid. Where should you look for the cause?
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 16 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.