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.

Python
  1. total = 20 # the scores added up
  2. count = 0 # how many scores were entered
  3. print("Working out the average...")
  4. result = total / count
  5. 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 = 60
players = int(input("How many players? "))
print("Sharing out the points...")
print("Each player gets", points / players)

Variables

points=60

Step 1. points holds 60.

Step 1 of 4Called right: 0 of 1

Think about what line 3 has to do with the value players holds.

Computer Science · Run-time errors

Which of these sounds right?

Four students are talking about a program that stopped part-way through its run. Each says something different.

Which idea is closest to what you would have said?
How sure are you?

Computer Science · Explain it

Now say it in your own words

distance = 120 minutes = int(input("How many minutes? ")) speed = distance / minutes print("Speed:", speed)

Explain why this program was translated and started running, but crashed when the user typed 0. [4 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.

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

1A run-time (execution) error is a programming error that only shows up while the program is running.
2It does not break the rules of the language, so the program can be translated and can start running.
3The program may stop unexpectedly or crash.
4Division by zero is an example: a line such as result = total / count fails when count holds 0.
5Whether it happens can depend on the values in use, so the same program may work with some inputs and fail with others.

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?
An execution error.
What is a run-time error?
A kind of programming error. It is a fault that only shows up while the program is running.
Can a program with a run-time error be translated and started?
Yes. The error does not break the rules of the programming language.
What may happen when a run-time error occurs?
The program may stop unexpectedly or crash.
Why is result = total / count a run-time error risk when count holds 0?
The code is valid, but the division cannot be carried out with a divisor of 0, so the program may crash.
Why can the same program work with some inputs and fail with others?
Whether a run-time error happens depends on the values the program is working with.
"The translator accepted my program, so it has no errors." True or false?
False. Accepting only means the code obeys the language's rules; a run-time error is still possible.
A line crashes, but its code is valid. Where should you look for the cause?
At the values the line meets while running, such as a divisor of 0, not for a broken rule.

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 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.