Edexcel GCSE Computer Science June 2024 Paper 1, Question 1: reading a program by line number
Pearson Edexcel 1CP2/01 June 2024, Question 1(c), (e) and (f): give the line numbers of a condition-controlled loop, iteration over a list and a selection in a colours program, the result of 5 // 2, and which search and sort are divide and conquer. Worked through, with the program to run.
Question 1 of the Pearson Edexcel GCSE Computer Science Paper 1 sat on 15 May 2024 (1CP2/01, Principles of Computer Science) opens the paper with computational thinking, 16 marks. This page works through the parts about code: (c), (e) and (f).
We do not copy the paper here. Open it beside this page: Edexcel June 2024 Paper 1 question paper (PDF). When you have finished, check the mark scheme too.
Part (c): the constructs (3 marks)
The program has a list of five colours. Line 11 is for item in theColours, which prints each one. Line 14 reads a colour. Line 15 is while (colour != ""). Lines 16 to 19 are an if that says Green is the favourite and an else that says any other colour is good. Line 21 reads the next colour.
- The first line of a condition-controlled loop: 15. A
whileruns until its condition changes. - The first line of iteration over every item in a data structure: 11. A
for ... inover the list. - The line numbers of a selection: 16 to 19. The
ifand itselsetogether. "16" on its own is refused.
Part (e)(ii): 5 // 2 (1 mark)
// is integer division: how many whole times 2 goes into 5. The answer is 2. Not 2.5 (that is /), and not 1 (that is 5 % 2, the remainder).
Part (f)(i): which algorithms? (2 marks)
- A search that is divide and conquer: binary search. It halves the array on every comparison.
- A sort that is not divide and conquer: bubble sort. It swaps neighbours pass after pass. (Merge sort is divide and conquer, so it is the wrong answer here.)
Where the marks are lost
- Line 14 for the loop. The input on 14 is before the loop. The
whileis on 15. - Line 12 for the iteration. The question asks for the first line, which is the
for. - Only the
ifline for selection. Selection is the wholeif ... elseblock. - Merge sort for the sort. Read the row: it asks for one that is not divide and conquer.
Run it
The colours program from the paper. Enter colours, and an empty line to stop. Then the two division results.
The program
from bugbot import *
connect()
theColours = ["Green", "Blue", "Yellow", "Red", "Purple"]
colour = ""
for item in theColours:
print(item)
colour = input("Enter a colour: ")
while colour != "":
if colour == "Green":
led("green")
print("Green is my favourite colour")
else:
print(colour + " is a good colour")
colour = input("Enter a colour: ")
print("5 // 2 is", 5 // 2)
print("5 / 2 is", 5 / 2)
print("5 % 2 is", 5 % 2)
Questions
What are the answers to Edexcel 2024 Paper 1 Question 1(c)?
The condition-controlled loop starts on line 15, the iteration over the list on line 11, and the selection is lines 16 to 19.
What is 5 // 2 in Python?
- The // operator is integer division, which gives the whole number of times the second number goes into the first and drops the remainder.
What does divide and conquer mean?
Splitting a problem into smaller parts and solving those. Binary search halves the array each time, and merge sort splits the list into single items before merging. Bubble sort and linear search do not divide anything.
Every Edexcel 1CP2 question we have worked · Guide: Linear search and binary search explained
Learn it step by step
- F2.6 Condition-controlled loops: while Decisions and loops
- F1.9 Arithmetic operators Programming basics
- F5.6 Binary search Algorithms
This is our own explanation of a published exam question. It is not written or endorsed by Pearson, and the question paper and mark scheme remain Pearson's copyright. Read them on Pearson's site with the links on this page.