Time left2:00:00 Answered 0 of 33 90 marks
AQA 8525/1B 2 hours 90 marks Full length paper

GCSE Computer Science Paper 1: Computational Thinking and Programming Skills (Python)

A full length 8525/1B paper: algorithms in AQA pseudo-code, data types, Boolean expressions, trace tables, searching and sorting, subroutines, testing, string handling, records, 2D lists, an authentication routine and a 9 mark car park program.

Instructions

Time allowed
2 hours
Total marks
90
Calculator
You must not use a calculator.
  • Answer all the questions.
  • The number of marks for each question is shown in brackets. Use it as a guide to how much to write.
  • The clock at the top counts down from the real time allowed. When it reaches zero the paper is locked and marked, as it would be collected in the exam hall.
  • Answer the questions that ask for program code in Python, using meaningful variable names and indentation.
  • Algorithms in the figures are written in AQA pseudo-code or Python, as labelled.
  • Answer every question. Read each algorithm line by line, and trace it with real values before you answer. For the programming questions, run your program on the examples in the question before you move on.

Questions

Answer every question, then finish the paper to have it marked. Marking as you go teaches you far less.

90 marks
01.1Shade one lozenge to show the best definition of an algorithm.1 mark

Tick one box.

Mark scheme0 / 1
  • LD A sequence of steps that can be followed to complete a task
Model answer

An algorithm is a sequence of steps that solves a problem or completes a task. It is not tied to any language.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
01.2Shade one lozenge to show which computational thinking technique involves removing unnecessary detail from a problem.1 mark

Tick one box.

Mark scheme0 / 1
  • LA Abstraction
Model answer

Abstraction keeps only the details that matter. Decomposition breaks a problem into smaller problems.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
01.3Figure 1 shows an algorithm. The user enters two whole numbers. Complete the table to show the output for each pair of inputs.3 marks

Figure 1

AQA pseudo-code
a ← USERINPUT
b ← USERINPUT
IF a > b THEN
    c ← a - b
ELSE
    c ← b - a
ENDIF
OUTPUT c
abOutput
49
127
66

Mark scheme0 / 3
  • L5
  • L5
  • L0
Model answer

4 is not greater than 9, so c = 9 - 4 = 5. 12 is greater than 7, so c = 12 - 7 = 5. 6 is not greater than 6, so c = 6 - 6 = 0.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
01.4Shade one lozenge to show the purpose of the algorithm in Figure 1.1 mark

Tick one box.

Mark scheme0 / 1
  • LB It outputs the difference between the two numbers
Model answer

Whichever number is larger, the smaller is subtracted from it, so the output is always the difference.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
02.1A football club stores data about its matches. Shade one lozenge in each row to show the most suitable data type for each item.4 marks
IntegerRealBooleanCharacterString
The number of goals scored in a match
The average number of goals scored per match
Whether the match has been played yet
The name of the opposing team

Tick one box in each row.

Mark scheme0 / 4
  • LThe number of goals scored in a match: Integer
  • LThe average number of goals scored per match: Real
  • LWhether the match has been played yet: Boolean
  • LThe name of the opposing team: String
Model answer

Goals are whole numbers, an average can have a fractional part, played or not is true or false, and a team name is a string of characters.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
02.2Figure 2 shows one line of a Python program. State the value of each Python expression.5 marks

Figure 2

Python code
word = "COMPUTER"

Mark scheme0 / 5
  • L8
  • LM
  • LOMP
  • L3
  • L2
Model answer

COMPUTER has 8 characters. Indexes start at 0, so word[2] is M, and word[1:4] is the characters at indexes 1, 2 and 3: OMP. 17 // 5 is integer division, 3, and 17 % 5 is the remainder, 2.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
03.1Shade two lozenges to show which are examples of indefinite iteration.2 marks

Tick two boxes.

Mark scheme0 / 2
  • LA A WHILE loop that repeats until the user enters 0
  • LB A REPEAT ... UNTIL loop that repeats until a password is correct
  • LNo marks if more than 2 boxes are ticked
Model answer

Indefinite iteration repeats until a condition is met, so the number of repeats is not known in advance. A FOR loop that runs 10 times is definite iteration, and IF is selection.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
03.2Explain one reason why a programmer might use a named constant, such as VAT_RATE, instead of writing the value 0.2 each time it is needed.2 marks
Explain

Mark scheme0 / 2
  • LIf the value changes it only needs to be updated in one place
  • LThe name makes the program easier to read and understand, and the value cannot be changed by mistake while the program runs
Model answer

If the VAT rate changes, the programmer only has to update the constant in one place, rather than finding every 0.2 in the program and risking missing one.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
03.3Figure 3 shows the values of three Boolean variables in a Python program. State the value of each Python expression.3 marks

Figure 3

Python code
a = True
b = False
c = True

Mark scheme0 / 3
  • LTrue
  • LFalse
  • LTrue
Model answer

a and not b is True, so the whole OR is True. not a is False and b is False, so not a or b is False. and is worked out before or: a and b is False, and False or c is True.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
04.1Complete the trace table for the algorithm in Figure 4. The first row has been completed for you.3 marks

Figure 4

AQA pseudo-code
nums ← [3, 8, 2, 7]
largest ← nums[0]
total ← 0
FOR i ← 1 TO 3
    IF nums[i] > largest THEN
        largest ← nums[i]
    ENDIF
    total ← total + nums[i]
ENDFOR
OUTPUT largest
OUTPUT total
ilargesttotal
30
1
2
3

Mark scheme0 / 3
  • LRow 1: 8, 8
  • LRow 2: 8, 10
  • LRow 3: 8, 17
Model answer

i = 1: 8 > 3, so largest becomes 8 and total becomes 8. i = 2: 2 is not larger, total becomes 10. i = 3: 7 is not larger than 8, total becomes 17.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
04.2The algorithm in Figure 4 should output the total of all four numbers in nums. Explain why it does not, and how the algorithm could be corrected.2 marks
Explain

Mark scheme0 / 2
  • LThe first number, nums[0] (3), is never added to total because the loop starts at 1
  • LSet total to nums[0] at the start, or make the loop run from 0 to 3
Model answer

The loop starts at index 1, so nums[0], the 3, is never added: the algorithm outputs 17 instead of 20. Setting total to nums[0] instead of 0 at the start fixes it.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
05.1Shade one lozenge to show which statement must be true for a binary search to be used on a list.1 mark

Tick one box.

Mark scheme0 / 1
  • LC The list must be in order
Model answer

A binary search discards half of the list at each step, which only works if the list is sorted.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
05.2A binary search is used to find Lemon in the list in Figure 5. The middle item is found with (first + last) DIV 2, where first and last are the positions of the first and last items still being searched. Complete the table to show the item checked at each comparison.3 marks

Figure 5

Position012345678
ItemAppleBananaCherryDateFigGrapeKiwiLemonMango
ComparisonItem checked
1
2
3

Mark scheme0 / 3
  • LFig
  • LKiwi
  • LLemon
Model answer

(0 + 8) DIV 2 = 4: Fig. Lemon comes after Fig, so first becomes 5. (5 + 8) DIV 2 = 6: Kiwi. Lemon comes after Kiwi, so first becomes 7. (7 + 8) DIV 2 = 7: Lemon, found.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
05.3Explain why a binary search is usually more efficient than a linear search for a large list.2 marks
Explain

Mark scheme0 / 2
  • LEach comparison halves the number of items still to be searched
  • Lso far fewer comparisons are needed, whereas a linear search may have to check every item
Model answer

Every comparison in a binary search discards half of the items that are left, so even a list of a million items needs only about 20 comparisons. A linear search checks the items one at a time and may have to look at all of them.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
05.4A bubble sort is used to put the list 5, 1, 4, 2 into ascending order. Complete the table to show the list after each of the first two passes.2 marks
Position 0Position 1Position 2Position 3
After pass 1
After pass 2

Mark scheme0 / 2
  • LRow 1: 1, 4, 2, 5
  • LRow 2: 1, 2, 4, 5
Model answer

Pass 1: 5 and 1 swap, 5 and 4 swap, 5 and 2 swap, giving 1, 4, 2, 5. Pass 2: 1 and 4 stay, 4 and 2 swap, 4 and 5 stay, giving 1, 2, 4, 5.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
05.5Shade one lozenge to show an advantage of merge sort compared with bubble sort.1 mark

Tick one box.

Mark scheme0 / 1
  • LD It is usually much faster for large lists
Model answer

Merge sort is far more time efficient on large lists. It needs extra memory for the lists it merges, and it is harder to write.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
06.1State the output when the program in Figure 6 is run.1 mark

Figure 6

Python code
def calculate(a, b):
    result = a * 2 + b
    return result

x = calculate(3, 4)
print(x)

Mark scheme0 / 1
  • L10
Model answer

calculate(3, 4) works out 3 * 2 + 4 = 10, which is returned, stored in x and printed.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
06.2Shade one lozenge in each row to show how each identifier is used in Figure 6.3 marks
ParameterLocal variableGlobal variable
a
result
x

Tick one box in each row.

Mark scheme0 / 3
  • La: Parameter
  • Lresult: Local variable
  • Lx: Global variable
Model answer

a and b receive the values passed in, so they are parameters. result is created inside the subroutine, so it is local. x is assigned in the main program, so it is global.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
06.3Explain two advantages of using subroutines when writing a large program.2 marks
Explain

Mark scheme0 / 2
  • LA subroutine can be called many times, so code is reused rather than written again
  • LEach subroutine can be written and tested on its own, or by different programmers, which makes the program easier to debug and maintain
Model answer

A subroutine can be called whenever it is needed, so the code is written once and reused. Each subroutine is a small, self-contained part that can be tested on its own, or written by a different member of a team, so errors are easier to find and the program is easier to maintain.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
07.1Shade one lozenge in each row to show whether each is an example of a syntax error or a logic error.2 marks
Syntax errorLogic error
Leaving out the closing bracket of print(
Using < instead of <= in a condition
Spelling the keyword while as whlie
Adding two numbers that should have been multiplied

Tick one box in each row.

Mark scheme0 / 2
  • L1 mark for both: Leaving out the closing bracket of print(: Syntax error; Using < instead of <= in a condition: Logic error
  • L1 mark for both: Spelling the keyword while as whlie: Syntax error; Adding two numbers that should have been multiplied: Logic error
Model answer

Breaking the rules of the language is a syntax error, so the program will not run. A program that runs but gives the wrong result has a logic error.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
07.2A program accepts a test mark, which must be a whole number from 0 to 50. Shade one lozenge in each row to show the type of each piece of test data.3 marks
NormalBoundaryErroneous
27
50
fifty

Tick one box in each row.

Mark scheme0 / 3
  • L27: Normal
  • L50: Boundary
  • Lfifty: Erroneous
Model answer

27 is a typical valid mark, 50 is at the edge of the allowed range, and fifty is the wrong type of data, so it should be rejected.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
07.3The program in Figure 7 should output the total of the whole numbers from 1 to 10, but it outputs 45. Shade one lozenge to show the line that contains the error.1 mark

Figure 7

Python code
01 total = 0
02 for i in range(1, 10):
03     total = total + i
04 print(total)

Tick one box.

Mark scheme0 / 1
  • LB 02
Model answer

range(1, 10) stops before 10, so 10 is never added and the total is 45 instead of 55.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
07.4Write the corrected version of the line you identified in 07.3.1 mark

Mark scheme0 / 1
  • Lfor i in range(1, 11):
Model answer

for i in range(1, 11):

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
08A website checks how strong a new password is. A password is strong if it has at least 8 characters and contains at least one digit.Write a Python program that:gets the user to enter a passwordoutputs Strong if the password is strongotherwise outputs Weak.5 marks
password.py

Mark scheme0 / 5
  • LGets a password from the user
  • LOutputs Strong for a long password that contains a digit, such as secure123
  • LOutputs Weak for a password with a digit that is too short, such as abc1
  • LOutputs Weak for a long password with no digit, such as abcdefghij
  • LTreats exactly 8 characters as long enough: abcdefg1 is Strong
A program that scores full marks

Check every character for a digit, then test both rules together with and, using >= 8 so that a password of exactly 8 characters counts.

Python
password = input("Enter a password: ")
hasDigit = False
for character in password:
    if character.isdigit():
        hasDigit = True
if len(password) >= 8 and hasDigit:
    print("Strong")
else:
    print("Weak")
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
09.1State the four values output by the algorithm in Figure 9. The character code for 'A' is 65.4 marks

Figure 9

AQA pseudo-code
word ← 'algorithm'
OUTPUT LEN(word)
OUTPUT SUBSTRING(0, 2, word)
OUTPUT POSITION(word, 'r')
OUTPUT CHAR_TO_CODE('B')

Mark scheme0 / 4
  • L9
  • Lalg
  • L4
  • L66
Model answer

algorithm has 9 characters. SUBSTRING(0, 2, word) gives the characters at positions 0 to 2 inclusive: alg. r is at position 4, counting from 0. B comes one after A, so its code is 66.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
09.2Write a Python program that gets the user to enter a word and outputs how many vowels (a, e, i, o and u) the word contains. Vowels in upper case and in lower case must both be counted.4 marks
vowels.py

Mark scheme0 / 4
  • LGets a word from the user
  • LOutputs 3 for banana
  • LCounts upper case vowels too: 5 for EDUCATION
  • LOutputs 0 for a word with no vowels, such as rhythm
A program that scores full marks

Loop through the word one letter at a time, converting each to lower case, and add one to a count whenever the letter is in "aeiou".

Python
word = input("Enter a word: ")
count = 0
for letter in word.lower():
    if letter in "aeiou":
        count = count + 1
print("Number of vowels:", count)
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
10.1The random module has been imported. Shade one lozenge to show which Python expression gives a random whole number from 1 to 6 inclusive.1 mark

Tick one box.

Mark scheme0 / 1
  • LC random.randint(1, 6)
Model answer

randint includes both of its end values, so randint(1, 6) gives 1, 2, 3, 4, 5 or 6.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
10.2Figure 10 shows a record used by a library program. Explain one advantage of storing the details of each book as a record rather than in four separate variables.2 marks
Explain

Figure 10

AQA pseudo-code
RECORD Book
    title : String
    author : String
    pages : Integer
    onLoan : Boolean
ENDRECORD

Mark scheme0 / 2
  • LAll the data about one book is kept together under one name
  • Lso it is easier to manage: a whole book can be passed to a subroutine, or many books stored in an array of records
Model answer

A record keeps all the related data about one book together under a single name. That makes the program easier to manage: a whole book can be passed to a subroutine in one go, and the library's books can be stored in a single array of Book records.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
11.1Three players take part in a quiz. Each row of the list in Figure 11 holds one player's scores in three rounds, so scores[1][0] is player 1's score in round 0. State the value of each.2 marks

Figure 11

Python code
scores = [[12, 15, 9],
          [20, 18, 22],
          [7, 11, 14]]

Mark scheme0 / 2
  • L22
  • L7
Model answer

scores[1] is the row [20, 18, 22], and item 2 of it is 22. scores[2] is [7, 11, 14], and item 0 of it is 7.

Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
11.2Write a Python subroutine called playerTotal that takes the 2D list of scores and a player number as parameters, and returns the total of that player's scores.3 marks
quiz.py

Mark scheme0 / 3
  • LDefines playerTotal with two parameters
  • LReturns 36 for player 0 in Figure 11
  • LWorks for any player and any number of rounds
A program that scores full marks

Loop through the player's row, scores[player], adding each score to a running total, then return the total.

Python
def playerTotal(scores, player):
    total = 0
    for score in scores[player]:
        total = total + score
    return total
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
11.3Write a Python subroutine called bestPlayer that takes the 2D list of scores as a parameter and returns the number of the player with the highest total. The subroutine playerTotal is given for you to use. You can assume no two players have the same total.4 marks
quiz.py

Mark scheme0 / 4
  • LDefines bestPlayer with one parameter
  • LReturns 1 for the scores in Figure 11
  • LWorks when the best player is the first or the last
  • LCompares each player's total over every round, for any number of players
A program that scores full marks

Keep the number of the best player so far, starting with player 0. Loop through the other players and, whenever one has a higher total, remember that player instead. Return the player number, not the total.

Python
def playerTotal(scores, player):
    total = 0
    for score in scores[player]:
        total = total + score
    return total


def bestPlayer(scores):
    best = 0
    for player in range(1, len(scores)):
        if playerTotal(scores, player) > playerTotal(scores, best):
            best = player
    return best
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
12A program must check a user's login details. The correct username and password are stored in the constants USERNAME and PASSWORD.Write a Python program that:gets the user to enter a username and a passwordoutputs Access granted if both are correctgives the user up to three attemptsoutputs Account locked if all three attempts are wrong.7 marks
login.py

Mark scheme0 / 7
  • LOutputs Access granted when both are correct
  • LChecks both the username and the password
  • LAllows a second attempt
  • LAllows a third attempt
  • LOutputs Account locked after three wrong attempts, without asking again
  • LEnds with Access granted, not Account locked, when the third attempt is right
  • LUses iteration to repeat the attempts
A program that scores full marks

Count the failed attempts in a loop that stops when the details are right or after three attempts, checking the username and the password together with and. After the loop, output one message or the other.

Python
USERNAME = "admin"
PASSWORD = "Secret99"

attempts = 0
granted = False
while attempts < 3 and not granted:
    username = input("Username: ")
    password = input("Password: ")
    if username == USERNAME and password == PASSWORD:
        granted = True
    else:
        attempts = attempts + 1
if granted:
    print("Access granted")
else:
    print("Account locked")
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
13A car park charges £2.00 an hour for each of the first 3 hours, and £1.50 for each hour after that. The most anyone pays is £15.00. Blue badge holders park for free.Write a Python program that:gets the user to enter the number of hours parked, as a whole numberkeeps asking until the number of hours is from 1 to 24gets the user to enter Y or N to say whether they have a blue badgecalculates the chargeoutputs the charge.9 marks
parking.py

Mark scheme0 / 9
  • LCharges £2.00 an hour up to 3 hours: 2 hours costs £4.00
  • LRejects fewer than 1 hour and asks again
  • LRejects more than 24 hours and asks again
  • LCharges £1.50 for each hour after the first 3: 5 hours costs £9.00
  • LGets the charge right below the maximum: 8 hours costs £13.50
  • LCharges no more than £15.00: 20 hours costs £15.00
  • LBlue badge holders pay nothing
  • LAccepts the boundary values 1 and 24
  • LUses a loop to repeat the validation
A program that scores full marks

Validate the hours with a while loop. Work out the charge for the first 3 hours and the hours after that separately, cap it at 15, and set it to 0 for a blue badge holder before outputting it.

Python
hours = int(input("Number of hours parked: "))
while hours < 1 or hours > 24:
    hours = int(input("Enter a whole number of hours from 1 to 24: "))
badge = input("Blue badge (Y/N)? ")
if hours <= 3:
    charge = hours * 2.00
else:
    charge = 3 * 2.00 + (hours - 3) * 1.50
if charge > 15:
    charge = 15.00
if badge == "Y":
    charge = 0
print("Charge: £" + format(charge, ".2f"))
Marked exactly against the mark scheme. Change it only if an examiner would accept your answer.
Machine mark 0 / 90
About this paper

This is an original paper modelled on the real AQA 8525/1B past papers: the same structure, the same balance of topics, the same command words and mark tariffs, 90 marks in 2 hours, exactly as the real paper allows. It is not a past paper. Real past papers are the copyright of the exam board and cannot be republished here, so links to the official papers on the board's own site are on the exam papers page.