AQA GCSE Computer Science June 2022 Paper 1, Question 2: nested selection and data types
AQA 8525 June 2022 Paper 1, Question 2: follow a nested IF with AND to find a takeaway delivery cost, then name the data types. Both outputs worked through, with the algorithm as a program to run.
Question 2 of the AQA GCSE Computer Science June 2022 Paper 1 (8525/1B, the Python paper) gives you a pseudo-code algorithm with an IF inside an IF. You work out its output for two sets of inputs (2 marks), then answer three short parts on Boolean values and data types (4 marks).
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 algorithm reads an order total and a delivery distance. It works out a delivery cost like this:
- The outer test: is the distance 5 or less and the order more than 0? If not, it outputs a message that delivery is not possible.
- Inside, if the order is more than 50, the delivery cost is 1.5.
- Else if the order is more than 25, the delivery cost is the order divided by 10, then multiplied by 2.
- Else it outputs a message that the minimum spend has not been met.
Part 1: the two outputs
Order 55.5, distance 2. Is 2 ≤ 5 and 55.5 > 0? Yes, so go inside. Is 55.5 > 50? Yes. The output is 1.5.
Order 35.0, distance 5. Is 5 ≤ 5? Yes: "less than or equal to" includes 5. And 35 > 0, so go inside. Is 35 > 50? No. Is 35 > 25? Yes. The cost is (35 / 10) * 2 = 3.5 * 2 = 7.0. The mark scheme accepts 7 as well.
Part 2: how many values can the comparison have?
deliveryDistance ≤ 5 is a comparison, and a comparison is either True or False. Two values.
Parts 3 and 4: data types
| Variable | Data type |
|---|---|
deliveryCost |
real (also called float or decimal) |
messageOne |
string |
deliveryCost holds values such as 1.5, so it cannot be an integer. messageOne holds text.
Part 4 asks for one more common data type that you have not already used. Any of Boolean, integer, character or date/time gets the mark. Real and string do not, because you gave them in Part 3.
Where the marks are lost
- Treating ≤ 5 as less than 5. A distance of exactly 5 is inside the delivery area.
- Stopping at the first inner test. 35 is not more than 50, so carry on to the
ELSE IF. - Doing the sum in the wrong order. Brackets first: 35 / 10, then times 2.
- "Number" as a data type. It is not one. Say integer or real.
- Repeating a type in Part 4. The question says "that you have not given".
Run it
The same algorithm in Python. The robot's light shows the result: green for a delivery cost, yellow for minimum spend not met, red for delivery not possible.
The program
from bugbot import *
connect()
order_total = float(input("Order total: "))
delivery_distance = float(input("Delivery distance: "))
delivery_cost = 0.0
if delivery_distance <= 5 and order_total > 0.0:
if order_total > 50.0:
delivery_cost = 1.5
led("green")
print(delivery_cost)
elif order_total > 25.0:
delivery_cost = (order_total / 10) * 2
led("green")
print(delivery_cost)
else:
led("yellow")
print("Minimum spend not met")
else:
led("red")
print("Delivery not possible")
Now change it
What does an order of exactly 50 cost to deliver? And exactly 25? Work them out, then run them. One of them may surprise you, and it shows why boundary values are worth testing.
Answer
50 is not more than 50, so it falls to the second test and costs (50 / 10) * 2 = 10.0. That is far more than the 1.5 that an order of 50.01 costs. 25 is not more than 25, so the minimum spend is not met.Questions
What are the answers to AQA GCSE Computer Science 2022 Paper 1 Question 2.1?
An order of 55.5 at a distance of 2 outputs 1.5. An order of 35.0 at a distance of 5 outputs 7.0.
How many values can a Boolean comparison have?
Two: True and False.
What are the common data types in GCSE Computer Science?
Integer (whole numbers), real or float (numbers with a decimal part), Boolean (True or False), character (one symbol) and string (text).
More from this paper
- Question 1: MOD, selection, assignment, relational operators and a definite loop 6 marks
- Question 9: String indexing, LEN and SUBSTRING 5 marks
Every AQA 8525 question we have worked
Learn it step by step
- F2.4 Nested selection and match Decisions and loops
- F1.8 Data types and casting 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.