AQA GCSE Computer Science Paper 1 (1B), June 2025: Question 11
14 marks · Hard difficulty · Programming
Trace a string-processing subroutine (findLetter) through multiple choice questions and write Python code extending a word guessing game program.
Practise this questionQuestion
Question text
11 A word game is being developed using Python.
A word is displayed as a series of asterisks (*) equal to the number of letters
in the word.
For example, the word apple would be displayed as *****
The player guesses one letter at a time. If the letter is in the word, the letter
will replace the asterisk(s) wherever the letter occurs.
For example, if the player enters p then the word apple will be displayed as
*pp**
Only lower-case letters are used in the word game.
Figure 12 shows a subroutine used in the program for this word game.
• Line numbers are included but are not part of the subroutine.
Figure 12
1 def findLetter(word, letter, hidden):
2 newHidden = ""
3 for i in range(len(word)):
4 if word[i] == letter:
5 newHidden = newHidden + letter
6 else:
7 newHidden = newHidden + hidden[i]
8 return newHidden
11.1 The subroutine call findLetter("system", "s", "*y**em") is made.
What is the value of the variable letter when line 4 is first executed?
Shade one lozenge.
[1 mark]
A *y**em
B s
C sys**m
D system 31
11.2 The subroutine call findLetter("system", "s", "*y**em")is made.
What is the value of the variable newHidden when line 6 is first executed?
Shade one lozenge.
[1 mark]
A s
B sys
C sys**m
D system
11.3 The subroutine call findLetter("system", "s", "*y**em") is made.
Identify how many times the loop would iterate.
Shade one lozenge.
[1 mark]
A 1
B 2
C 6
D 7
11.4 The subroutine call findLetter("system", "s", "*y**em") is made.
What value is returned?
Shade one lozenge.
[1 mark]
A s
B sy*tem
C sys*em
D system 32
11.5 A Python program is being written to determine if a player wins or loses the word
game.
• The player wins if they correctly guess all of the letters in the word within eight
*31*guesses or fewer.
• The player loses if they have had eight guesses and there are still letters remaining
that they have not guessed correctly.
Figure 13 shows the beginning of the program.
Figure 13
word = input()
hidden = ""
for i in range(len(word)):
hidden = hidden + "*"
Extend the program in Figure 13.
Your program must:
• keep repeating the following until the user has had eight guesses or there are no
asterisks left in hidden
o get the user to enter a letter
o call the findLetter subroutine (from Figure 12)
o update the value of hidden using the value returned from findLetter
o display the new value of hidden
• check if the new value of hidden contains any asterisks
o if there are any asterisks in hidden display the message You lost
o if there are no asterisks in hidden display the message You won
The program you write must not use any built-in routines to check if a string
contains another string/character or to count the number of asterisks.
You should use indentation as appropriate, meaningful variable name(s) and
Python syntax in your answer.
The answer grid below contains vertical lines to help you indent your code
accurately.
[10 marks]
word = input()
hidden = ""
for i in range(len(word)):
hidden = hidden + "*"
Mark scheme
Show the mark scheme
Total
Question Part Marking guidance
marks
11 1 Mark is for AO2 (apply) 1
B s;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 2 Mark is for AO2 (apply) 1
A s;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 3 Mark is for AO2 (apply) 1
C 6;
R. If more than one lozenge shaded
Total
Question Part Marking guidance
marks
11 4 Mark is for AO2 (apply) 1
C sys*em;
R. If more than one lozenge shaded
Marking guidance Total
Question Part
marks
11 5 2 marks for AO3 (design), 8 marks for AO3 (program) 10
Program Design
Note that AO3 (design) marks are for selecting appropriate techniques to
use to solve the problem, so should be credited whether the syntax of
programming language statements is correct or not and regardless of
whether the solution works.
Mark A for creating a new iteration construct that exists within their
language and inputting a letter within it;
Mark B for the use of a selection structure for both the messages about
winning and losing;
Program Logic
Mark C for an iteration structure that correctly allows a letter to be entered a
maximum of 8 times (I. any reference to exiting the loop based on the
number of asterisks);
Mark D for an iteration structure that exits correctly when there are no
asterisks left in hidden and there is a correct boolean joining operator for
BOTH conditions (See Mark C for second condition);
Mark E for correctly calling the findLetter subroutine within an iteration
structure (even if the parameters are incorrect or missing);
Mark F for including the correct parameters in the correct order when calling
the findLetter subroutine; Note: the middle parameter should match
the variable name their user input has been assigned to.
Mark G for updating the hidden variable with the return value from the call
to findLetter; R. if hidden is re-initialised within the iteration structure
Mark H for correctly checking to see if there are any asterisks left in
hidden and handling it appropriately;
Mark I for displaying the value of hidden after each attempt;
Mark J for displaying You won and You lost in appropriate places
under the correct conditions;
Note to Examiners
If used built in routines to check if a string contains another string/character
or to count the number of asterisks then do not award marks D and H
I. Case
I. Messages or no messages with input statements
I. Gaps/spaces throughout the code, except where to do so would explicitly
alter the logic of the code in a way that makes it incorrect.
Maximum 9 marks if any errors in code.
Note to examiners
In C#/VB.NET examples, explicit variable declarations are not shown. Refer
to the specific language type issues section of the appropriate Marking
Guidance document. Any correct variable declarations in student answers
should be accepted.
C# Example 1 (fully correct)
All design marks are achieved (Marks A and B)
won = false; Part D
for (i = 0; i < 8; i++) { C
letter = Console.ReadLine();
hidden = findLetter(word, letter, hidden); EFG
Console.WriteLine(hidden); I
won = true; Part D
for (j = 0; j < hidden.Length; j++) { Part H
if (hidden[j] == '*') { Part H
won = false; Part H
}
}
if (won == true) { Part D
break; Part D
}
}
if (won == false) { Part J
Console.WriteLine("You lost"); Part J
} else { Part J
Console.WriteLine("You won"); Part J
}
A. Write in place of WriteLine;
I. missing Console.MARKSCHEME – COMPUTER SCIENCE – – JUNE 2025
VB.NET Example 3 (fully correct)
All design marks are achieved (Marks A and B)
won = False Part D
For count = 1 To 8 C
letter = Console.ReadLine()
hidden = findLetter(word, letter, hidden) EFG
Console.WriteLine(hidden) I
If word = hidden Then Part D, H
won = True Part D
Console.WriteLine("You won") Part J
Exit For Part D
End If
Next 31
If won = False Then Part J
Console.WriteLine("You lost") Part J
End If
A. Write in place of WriteLine;
I. missing Console.
How to answer it
Word Guessing Game: Subroutines, String Traversal & Iteration
This question assesses your ability to read, trace, and write Python programs using fundamental algorithmic constructs:
- Subroutine Tracing (11.1–11.4): Parameter passing, tracking variable states during loop execution, string indexing ( string[i] ), and loop iterations.
- Algorithm Design & Implementation (11.5): Constructing controlled loops (maximum 8 iterations or until win condition), calling subroutines with arguments, capturing return values, checking string characters manually without forbidden built-in methods (like in or count() ), and selection structures ( if-else ).
Parts 11.1 to 11.4: Tracing the Subroutine
Analysis of findLetter("system", "s", "*y**em")
11.1 Variable value of letter [1 mark]
Correct Answer: B ( s )
The subroutine definition is def findLetter(word, letter, hidden): . The second argument passed in the call is "s" , so the parameter letter holds the value "s" throughout execution.
11.2 Value of newHidden at Line 6 [1 mark]
Correct Answer: A ( s )
On iteration i = 0 , word[0] is 's' . Since 's' == 's' , line 5 runs: newHidden = "" + "s" = "s" . Line 6 is reached only on iteration i = 1 when word[1] is 'y' ( 'y' != 's' ). At this exact moment, newHidden is still "s" .
11.3 Number of loop iterations [1 mark]
Correct Answer: C ( 6 )
The loop runs for i in range(len(word)) . The string "system" has 6 characters, so len("system") = 6 . The loop iterates exactly 6 times ( i = 0, 1, 2, 3, 4, 5 ).
11.4 Returned value [1 mark]
Correct Answer: C ( sys*em )
The function reconstructs the string by checking each letter of "system" against 's' :
- i=0: 's' == 's' → 's'
- i=1: 'y' != 's' → take hidden[1] ('y') → 'sy'
- i=2: 's' == 's' → 'sys'
- i=3: 't' != 's' → take hidden[3] ('*') → 'sys*'
- i=4: 'e' != 's' → take hidden[4] ('e') → 'sys*e'
- i=5: 'm' != 's' → take hidden[5] ('m') → 'sys*em'
❌ Common Pitfalls in Tracing Questions
- Confusing the loop variable with the string value: In 11.1, students often pick 'system' or '*y**em' by confusing parameter order. Look carefully at the header: (word, letter, hidden) .
- Off-by-one errors on line execution: In 11.2, line 6 is an else: statement. It is bypassed completely when i = 0 because the if condition was true! It only triggers when i = 1 .
Part 11.5: Program Extension (10 Marks)
Writing the Game Loop & Win/Loss Logic
🧠 Constraint Checklist (Read Before Writing Code!)
- Must iterate a maximum of 8 times.
- Must stop early if there are no asterisks left in hidden .
- Strict Restriction: Must NOT use built-in functions like '*' in hidden or hidden.count('*') . Checking for asterisks must be done manually via a loop or equivalent logic!
- Must call findLetter with three arguments in the exact order: (word, letter, hidden) .
- Must update hidden with the returned value and display it after each guess.
- Must output exactly You won or You lost .
✅ Model Full-Mark Solution (Python 3)
guesses = 0 hasAsterisk = True while guesses < 8 and hasAsterisk == True: guess = input("Enter a letter: ") hidden = findLetter(word, guess, hidden) print(hidden) guesses = guesses + 1 # Check if any asterisks remain (without using 'in' or count()) hasAsterisk = False for i in range(len(hidden)): if hidden[i] == "*": hasAsterisk = True if hasAsterisk == False: print("You won") else: print("You lost")📐 Mark Breakdown (10 Marks Total)
Design Marks (AO3 - 2 marks):
- Mark A: Creates an iteration construct that inputs a letter inside it.
- Mark B: Uses selection ( if/else ) to handle both win and loss messages.
Logic & Programming Marks (AO3 - 8 marks):
- Mark C: Loop allows maximum 8 inputs.
- Mark D: Loop exits when no asterisks remain (with correct boolean operator).
- Mark E: Calls findLetter inside loop.
- Mark F: Supplies correct arguments (word, letter, hidden) .
- Mark G: Updates hidden with the return value ( hidden = findLetter(...) ).
- Mark H: Manually traverses string to check for asterisks without built-in methods.
- Mark I: Prints/displays hidden after each guess.
- Mark J: Correct conditional messages: "You won" and "You lost" .
❌ Critical Pitfalls & Examiner Warnings
- Using forbidden built-ins: Writing if "*" in hidden: or hidden.count('*') immediately loses Mark D and Mark H. You must manually loop across the indices or characters of hidden .
- Re-initialising hidden : Writing hidden = "" inside the 8-guess loop resets the user's progress every turn, losing Mark G.
- Forgetting to assign the return value: Simply writing findLetter(word, guess, hidden) without hidden = ... discards the updated string! Subroutines in Python return a new string; strings are immutable.
- Case Sensitivity: The question requires printing You won and You lost . Avoid altering the wording or case.
Topics
3.1 Fundamentals of algorithms · 3.2 Programming · 3.1.1 Representing algorithms · 3.2.2 Programming concepts · 3.2.7 Input/output · 3.2.8 String handling operations in a programming language · 3.2.10 Structured programming and subroutines (procedures and functions)
Question and mark scheme from the AQA GCSE Computer Science examination, Paper 1 (1B), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.