Edexcel GCSE Computer Science June 2025 Paper 2, Question 1: nine errors in the meal program

Pearson Edexcel 1CP2/02 June 2025, Question 1: fix three syntax errors, a TypeError, two NameErrors and three logic errors in a Python program that discounts a restaurant bill. Each fix explained, with the working program to run on the paper's test data.

Past paper questionPearson 1CP2/02June 2025 Paper 29 marksFix the code

Question 1 of the Pearson Edexcel GCSE Computer Science Paper 2 sat on 20 May 2025 (1CP2/02, Application of Computational Thinking) is a 9 mark debugging question: nine faulty lines, one mark each. The paper names the line and the kind of error every time.

We do not copy the exam paper or Pearson's code files here. Open the paper beside this page: Edexcel June 2025 Paper 2 question paper (PDF). When you have finished, check the mark scheme too.

The question in short

A restaurant program takes the number of two-course meals, three-course meals and drinks. More than eight meals gets 15% off. Otherwise more than four three-course meals gets 10% off. Otherwise more than two two-course meals gets 5% off. Only one discount applies. If the drinks do not match the number of meals, an error is shown and nothing is calculated.

The nine fixes

Error The fix
Syntax: a comment with no # after a value put # in front of Cost of meals
Syntax: a space in a variable name costDrinks = 2.00
Syntax: 0 = numDrinks numDrinks = 0. The variable goes on the left
TypeError: a variable name in quotation marks is multiplied total = num2Courses * cost2Courses
NameError: cost33Courses cost3Courses
NameError: tatol total
Logic: the 15% test subtracts the meals num2Courses + num3Courses > 8
Logic: 15% off is done with + total = 0.85 * total
Logic: the final print is not indented under the else indent it, so it only prints when the drinks match

Where the marks are lost

  • Deleting the comment instead of marking it. The mark scheme refuses that.
  • Renaming costDrinks to cost or Drinks. Join the two halves.
  • Fixing the TypeError by casting. int("num2Courses") is still wrong. The quotes should not be there.
  • Guessing at the logic errors. Test with the paper's data. 5 two-course, 6 three-course and 11 drinks should give 184.45. If you get a different number, the 15% branch is still wrong.

Run it

The corrected program on the paper's test data. The last row shows the mismatch message.

5, 6 and 11 drinks give 184.45 (15% off). 1, 5 and 6 give 114.3 (10% off). 5, 0 and 5 give 80.75 (5% off). 2, 2 and 5 drinks do not match.
The program
from bugbot import *
connect()

cost2Courses = 15.00     # Cost of meals
cost3Courses = 20.00
costDrinks = 2.00

num2Courses = 0
num3Courses = 0
numDrinks = 0

num2Courses = int(input("Two-course meals: "))
num3Courses = int(input("Three-course meals: "))
numDrinks = int(input("Drinks: "))

if numDrinks != num2Courses + num3Courses:
    led("red")
    print("Meals and drinks don't match")
else:
    total = num2Courses * cost2Courses
    total = total + num3Courses * cost3Courses
    total = total + numDrinks * costDrinks
    if num2Courses + num3Courses > 8:
        total = 0.85 * total
    elif num3Courses > 4:
        total = 0.90 * total
    elif num2Courses > 2:
        total = 0.95 * total
    led("green")
    print("Total is:", total)
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is a TypeError in Python?

An operation on the wrong type of data, such as multiplying a string by a decimal number. Here the variable name was in quotation marks, which made it a string.

Why must the variable go on the left of an assignment?

An assignment stores the value on the right in the variable on the left. 0 = numDrinks tries to store a variable in the number 0, which is a syntax error.

How do I find a logic error?

Run the program with test data whose answer you know, such as the rows in the question paper, and compare the output. Then trace the lines that made the wrong part of it.

More from this paper

Every Edexcel 1CP2 question we have worked · Guide: Logic gates and truth tables explained

Learn it step by step

  1. F1.4 Errors: syntax, runtime and logic Programming basics
  2. F6.4 Debugging logic errors Robust programs
  3. F2.3 else, elif and Boolean operators Decisions and loops
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by Pearson, and the question paper and mark scheme remain Pearson's copyright. Read them on Pearson's site with the links on this page.