AQA GCSE Computer Science sample Paper 1, Question 3: the dog biscuit algorithm
AQA 8525 sample assessment material, Paper 1 Question 3: read an ELSE IF chain and a FOR loop that dispense dog biscuits. Where selection and iteration start, how many subroutine calls, a data type, and counting the calls with one parameter. With the algorithm to run.
Question 3 of AQA's sample assessment material for GCSE Computer Science Paper 1 (8525/1B, the Python paper) is five one mark parts about one 17 line algorithm. It is the shape of the first "read the code" question on every real paper since.
We do not copy the paper here. Open it beside this page: AQA 8525 Paper 1B sample question paper (PDF). When you have finished, check the sample mark scheme too.
The question in short
The algorithm reads a time of day. If it is breakfast, q is 1. Else if lunch, q is 4. Else if dinner, q is 2. Otherwise it outputs that the time is not recognised. Then a loop runs n from 1 to q: for n less than 3 it calls DISPENSE_BISCUIT('chewies'), and otherwise DISPENSE_BISCUIT('crunchy').
The five parts
3.1 Where is selection first used? Line 2, the first IF.
3.2 Where is iteration first used? Line 11, the FOR.
3.3 How many calls for 'breakfast'? q is 1, so the loop runs once: 1 call.
3.4 The data type of time. It holds words such as 'lunch': string.
3.5 How many calls with 'chewies' for 'lunch'? q is 4, so n goes 1, 2, 3, 4. The chewies branch runs while n is less than 3: for n = 1 and 2. Two.
Where the marks are lost
- Line 1 for selection. Input is not a choice.
- 4 for part 3.5. Four is the total number of calls. Only two of them pass 'chewies';
n= 3 and 4 get 'crunchy'. - "Date/Time" for the data type. The name of the variable is not its type. Look at what is stored in it.
- Counting the
ELSE IFlines as loops. They choose once. Nothing repeats until line 11.
Run it
The algorithm with a DISPENSE_BISCUIT that prints, and counts, what it dispenses. The robot nudges forward for each biscuit.
The program
from bugbot import *
connect()
chewies = 0
crunchy = 0
def DISPENSE_BISCUIT(kind):
global chewies, crunchy
print("dispensing", kind)
if kind == "chewies":
chewies = chewies + 1
else:
crunchy = crunchy + 1
forward(60, distance=4)
q = 0
time = input("Time of day: ")
if time == "breakfast":
q = 1
elif time == "lunch":
q = 4
elif time == "dinner":
q = 2
else:
print("time not recognised")
for n in range(1, q + 1):
if n < 3:
DISPENSE_BISCUIT("chewies")
else:
DISPENSE_BISCUIT("crunchy")
print(chewies, "chewies and", crunchy, "crunchy")
Questions
What are the answers to AQA sample Paper 1 Question 3?
3.1 line 2. 3.2 line 11. 3.3 one call. 3.4 string. 3.5 two calls with chewies.
How do I count how many times a loop runs?
A FOR loop from 1 TO q runs q times, with the counter taking every value from 1 to q. Then check the condition inside the loop for each value of the counter.
What is the difference between selection and iteration?
Selection chooses between paths once, using IF. Iteration repeats a block of code, using FOR, WHILE or REPEAT.
More from this paper
Every AQA 8525 question we have worked · Guide: Logic gates and truth tables explained
Learn it step by step
- F2.3 else, elif and Boolean operators Decisions and loops
- F2.5 Count-controlled loops: for 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.