GCSE (9-1) Computer Science
Mark Scheme
J277/02: Programming Constructs & Logic
Question Answer Marks Guidance
1 1. ELIF (or ELSE IF) (1)
2. ELSE (1)
2
Python uses elif. ERL uses elseif. Both accepted.
IF is incorrect for the second gap as it would start a new logic chain.
ELSE catches all remaining values (>10).
2a if choice == "A":
  print("Add")
elif choice == "S":
  print("Subtract")
else:
  print("Invalid")
3
1 mark: Correct == syntax.
1 mark: Correct use of elif for option S.
1 mark: Correct use of else for default.
2b Code is cleaner / easier to read OR optimised by compiler (jump table). 1
"It's faster to write" is too vague. Focus on readability.
3a 13 1
x starts at 10. 10 > 5 is True -> x = 15. 15 > 12 is True -> x = 13. Sequence matters!
3b 15 1
If using elif, the second condition is skipped because the first one was true.
4a For Loop (Count-Controlled). We know the specific number of iterations (5) before the loop starts. 2
1 mark for "For Loop".
1 mark for justification regarding "Fixed number of times".
4b While Loop (Condition-Controlled). We do not know how many times it will loop; it depends on the user input. 2
1 mark for "While Loop".
1 mark for justification regarding "Unknown iterations" or "Depends on condition".
5a The variable num is never updated/incremented, so num <= 5 is always True. 1
Must mention "variable not changing" or "condition remains true".
5b num = num + 1 OR num += 1 1
6a 0, 1, 2, 3, 4, 5, 6, 7 1
Outputs all integers up to (but not including) 8.
6b for i in range(0, 9, 2):
OR
for i in range(0, 10, 2):
2
1 mark for Start/End values covering 8.
1 mark for Step of 2.
7 Rows must show:
1. i=1, j=1, total=1 (given)
2. i=1, j=2, total=2 -> Output 2 (from code trace, although print is outside loops)
Correction to Question Logic vs Answer Key: The trace table usually tracks state changes.
Correct sequence of 'total':
1 + 1 = 2 (i=1, j=2)
2 + 2 = 4 (i=2, j=1)
4 + 2 = 6 (i=2, j=2)
6 + 3 = 9 (i=3, j=1)
9 + 3 = 12 (i=3, j=2)
Final Output: 12.
5
1 mark per correct row state update.
1 mark for final correct output (12).
8 1. 7, True, 7 (1)
2. 4, True, 4 (1)
3. 1, True, 1 (1)
4. -2, False, Blastoff (1)
4
Final state (-2) causes loop to break. Output "Blastoff".
9 choice = int(input...)
if choice >= 1 and choice <= 3:
  # Valid logic
else:
  print("Error")

(Accept choice == 1 or choice == 2...)
4
1 mark: Removing valid flag.
1 mark: Using OR / AND.
1 mark: Using ELSE for error.
1 mark: Logic works correctly.
10 Marking Points:
1. count = int(input(...)) (Inputting number of students) (1)
2. total = 0 (Initialising total outside loop) (1)
3. for i in range(count): (Correct Count-Controlled loop) (1)
4. score = int(input(...)) (Input inside loop) (1)
5. if score < 0: print("Invalid") else: total += score (Validating/Updating) (1)
6. print(total / count) (Calculation and Output) (1)
6
11 guess = 0
while guess != 7:
  guess = int(input("Guess"))
print("Found it!")
3
1 mark: Correct While condition logic.
1 mark: Input inside the loop.
1 mark: Output outside the loop (after it finishes).