AQA GCSE Computer Science June 2022 Paper 1, Question 3: the car park program
AQA 8525 June 2022 Paper 1, Question 3: rewrite two lines of a Python car park program, one to concatenate strings and one to change a calculation. Both answers explained, with the finished program to run.
Question 3 of the AQA GCSE Computer Science June 2022 Paper 1 (8525/1B, the Python paper) shows an eleven line Python program and asks you to rewrite two of its lines. One mark each. This kind of question is called refining: you change working code to meet a new need.
We do not copy the exam paper here. Open it beside this page: AQA June 2022 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.
The question in short
The program asks for a car registration. While the registration is longer than 8 characters, it shows a message and asks again. Then it asks for the length of the stay in hours. Under 2 hours is free. Otherwise the charge is 2 for each hour.
Part 1. Line 4 sets the message to " is not valid". Rewrite it so that the message is the registration joined to that text.
Part 2. Parking for two hours or more now has an extra £2 fee. Rewrite line 10, which works out hours * 2.
The answers
Part 1. Joining strings is concatenation, and in Python the operator is +:
displayMessage = carReg + " is not valid"
Part 2. Add 2 to the charge:
charge = hours * 2 + 2
Where the marks are lost
- Putting the variable name inside the quotes.
"carReg is not valid"is just that text. The variable must be outside the quotation marks. - Using a comma.
carReg, " is not valid"makes a pair of values, not one string. A comma only joins things insideprint. hours * (2 + 2). That is 4 for each hour. The fee is added once, after the multiplication. Extra brackets are fine so long as they do not change the answer.- Writing pseudo-code. Both parts say the answer must be in Python.
Run it
The finished program with both changes made.
The program
from bugbot import *
connect()
charge = 0
carReg = input("Enter your car registration: ")
while len(carReg) > 8:
displayMessage = carReg + " is not valid"
led("red")
carReg = input(displayMessage + ". Try again: ")
led("green")
hours = int(input("Enter your stay in hours: "))
if hours < 2:
charge = 0
else:
charge = hours * 2 + 2
print(charge)
Questions
What are the answers to AQA GCSE Computer Science 2022 Paper 1 Question 3?
Line 4 becomes displayMessage = carReg + " is not valid". Line 10 becomes charge = hours * 2 + 2.
What is concatenation?
Concatenation is joining two strings end to end to make one string. In Python the + operator does it, so "MA19" + " GHJ" makes "MA19 GHJ".
What does refining a program mean?
Refining means changing a program that already exists so that it works better or meets a new requirement. AQA tests it by asking you to rewrite particular lines.
More from this paper
Every AQA 8525 question we have worked
Learn it step by step
- F3.1 String handling Strings, lists and records
- F1.9 Arithmetic operators Programming basics
This is our own explanation of a published exam question. It is not written or endorsed by AQA, and the question paper and mark scheme remain AQA's copyright. Read them on AQA's site with the links on this page.