Edexcel GCSE Computer Science

Paper 2: Application of Computational Thinking - FORECAST EXAM 3

⏱️ 2 hours πŸ“ 75 marks πŸ’» 6 Questions

πŸŽ“ PRACTICE MODE

PLS hints shown in yellow. In the real exam, you must find this in the PLS yourself!

Question 1: Pizza Order Calculator

πŸ“Š 10 marks⏱️ 15 minsπŸ“‚ Q01FINISHED.py

A pizza restaurant calculates order totals. The base prices depend on pizza size.

Prices:

SizeCodePrice
SmallSΒ£6.99
MediumMΒ£9.99
LargeLΒ£12.99

Additional rules:

  • Extra toppings cost Β£1.50 each
  • Orders of 3 or more pizzas get 10% off the total
  • Delivery adds Β£2.50 (Y/N input)

Requirements:

  • Store topping price and delivery charge as constants
  • Input: size code, number of extra toppings, quantity, delivery (Y/N)
  • Calculate total and display to 2 decimal places
SizeToppingsQtyDeliveryOutput
M21NΒ£12.99
L13YΒ£41.62
S02NΒ£13.98

πŸ“– PLS: Data Types (p.5), Selection (p.7), Formatting (p.12)

Constants: TOPPING_PRICE = 1.50 DELIVERY_CHARGE = 2.50 Input: size = input("prompt").upper() toppings = int(input("prompt")) Selection: if size == "S": price = 6.99 elif size == "M": Discount: total = total * 0.9 (10% off) Format: "Β£{:.2f}".format(total)
⚠️ IN THE REAL EXAM: No hints! Find this in your PLS document.
πŸ“ Q01.py
πŸ’» Output
Output here...

Question 2: Debugging - Turtle Traffic Light

πŸ“Š 10 marks⏱️ 15 minsπŸ“‚ Q02FINISHED.py

A program draws a traffic light with three filled circles (red, amber, green from top to bottom). The program has errors.

Fix these errors:

  • Line 1: NameError - wrong module name
  • Line 6: SyntaxError - missing closing bracket
  • Line 9: AttributeError - method name wrong (begin_fil)
  • Line 11: Logic error - circle should have radius 30, not 300
  • Add a comment on line 14 explaining what penup() does
  • Complete line 20 to set fill colour to "orange" for amber light
  • Complete line 27 to end the fill for the green light

πŸ“– PLS: Turtle Graphics (p.14-16)

Import: import turtle Create: t = turtle.Turtle() Circle: t.circle(radius) Fill: t.fillcolor("red") t.begin_fill() t.circle(30) t.end_fill() Pen: t.penup() - lifts pen (no drawing while moving) t.pendown() - lowers pen
⚠️ Real exam: Check PLS pages 14-16 for turtle syntax!
πŸ“ Q02.py
πŸ’» Output
Click Run to draw the traffic light!

Question 3: Temperature Converter

πŸ“Š 10 marks⏱️ 20 minsπŸ“‚ Q03FINISHED.py

A program converts temperatures between Celsius and Fahrenheit.

Formulas:

  • Celsius to Fahrenheit: F = (C Γ— 9/5) + 32
  • Fahrenheit to Celsius: C = (F - 32) Γ— 5/9

Requirements:

  • Input the temperature as a decimal number
  • Input the conversion direction (C for Celsiusβ†’Fahrenheit, F for Fahrenheitβ†’Celsius)
  • Validate: Celsius cannot be below -273.15 (absolute zero)
  • Validate: Fahrenheit cannot be below -459.67 (absolute zero)
  • Display result rounded to 1 decimal place with appropriate unit
TempDirectionOutput
100C212.0Β°F
32F0.0Β°C
-300CInvalid temperature
-500FInvalid temperature

πŸ“– PLS: Conversion (p.5), Operators (p.6), round() (p.9)

Float input: temp = float(input("prompt")) Division: Use / for decimal division Rounding: round(value, 1) for 1 decimal place Selection: if direction == "C": if temp >= -273.15: result = (temp * 9/5) + 32 Output: print(str(result) + "Β°F")
⚠️ Check your boundary values carefully!
πŸ“ Q03.py
πŸ’» Output
Output here...

Question 4: Dice Game Score Calculator (Parsons)

πŸ“Š 15 marks⏱️ 20 minsπŸ“‚ Q04FINISHED.py

A dice game rolls two dice. The score depends on the result:

  • Double 6: Score = 25 points
  • Any other double: Score = total Γ— 2
  • Not a double: Score = total

The game plays 3 rounds and totals the score.

RoundDice 1Dice 2Round Score
16625
23312
3426
Total43

Rearrange the lines. DO NOT change indentation!

πŸ“– PLS: random.randint() (p.13), for loop (p.7), Selection (p.7)

Import: import random For loop: for round in range(3): Random: dice1 = random.randint(1, 6) Double check: if dice1 == dice2: Nested: if dice1 == 6: score = 25 else: score = (dice1 + dice2) * 2
⚠️ NEVER change indentation in Parsons problems!
πŸ“ Q04.py
πŸ’» Output
Output here...

Question 5: Employee Payroll Calculator

πŸ“Š 15 marks⏱️ 25 minsπŸ“‚ Q05FINISHED.py

A company stores employee data in a file. Each line contains: Name, Hours Worked, Hourly Rate (separated by commas).

File Q05_DATA.txt: Jones,40,15.50 Smith,45,12.00 Brown,38,18.75 Wilson,50,14.25 Taylor,35,20.00

Requirements:

  • Create a function calculatePay(hours, rate) that:
    • Pays normal rate for first 40 hours
    • Pays 1.5Γ— rate for overtime (hours over 40)
    • Returns total pay
  • Read data from file and calculate pay for each employee
  • Write Name and Pay (to 2dp) to Q05_OUTPUT.txt
  • Display total payroll cost

Expected calculations:

NameHoursRatePay
Jones4015.50Β£620.00
Smith4512.00Β£570.00

Smith: 40Γ—12 + 5Γ—(12Γ—1.5) = 480 + 90 = Β£570

πŸ“– PLS: Files (p.8), Functions (p.8), split/strip (p.11)

Function: def calculatePay(hours, rate): if hours <= 40: return hours * rate else: normal = 40 * rate overtime = (hours - 40) * rate * 1.5 return normal + overtime File: for line in file: parts = line.strip().split(",") hours = float(parts[1]) Write: file.write(name + "," + "{:.2f}".format(pay) + "\n")
⚠️ Remember: overtime is hours OVER 40, not all hours!
πŸ“ Q05.py
πŸ’» Output
File ops simulated. Test in IDLE.

Question 6: Hotel Room Booking System

πŸ“Š 15 marks⏱️ 25 minsπŸ“‚ Q06FINISHED.py

A hotel stores room information in a 2D array. Each record contains: Room Number, Type, Price per Night, Available (True/False).

The array is sorted by Room Number.

Write a program to:

  • Display all available rooms with their type and price
  • Accept a room number from the user to book
  • Search for the room using linear search
  • If found AND available: display booking confirmation and price, mark as unavailable
  • If found but NOT available: display "Room already booked"
  • If not found: display "Room not found"
RoomTypePriceAvailable
101SingleΒ£75True
102DoubleΒ£120False
201DoubleΒ£120True
202SuiteΒ£250True

πŸ“– PLS: 2D arrays (p.5), len() (p.9), Boolean (p.5)

Display available: for i in range(len(rooms)): if rooms[i][3] == True: print(rooms[i][0], rooms[i][1], rooms[i][2]) Linear search: found = False i = 0 while i < len(rooms) and not found: if rooms[i][0] == searchRoom: found = True else: i = i + 1 Update array: rooms[i][3] = False # Mark as booked
⚠️ Remember to UPDATE the array when booking!
πŸ“ Q06.py
πŸ’» Output
Output here...