Edexcel GCSE · PastPaper.sampleTitle

MetadataPastPaper.sampleTitle

Thinka Jun 2022 Pearson Edexcel GCSE-Style Mock — Computer Science (1CP2)

150 PastPaper.marks210 PastPaper.minutes2022
An original Thinka practice paper modelled on the structure and difficulty of the Jun 2022 Pearson Edexcel GCSE Computer Science (1CP2) paper. Not affiliated with or reproduced from Pearson.

Paper 1: Principles of Computer Science

Answer all questions in the space provided. Calculators are not allowed.
30 PastPaper.question · 85 PastPaper.marks
PastPaper.question 1 · multiple_choice
2 PastPaper.marks
An 8-bit register contains the binary pattern 0011 1100. A logical right shift of 2 places is performed on the pattern. What is the resulting denary value?
  1. A.15
  2. B.30
  3. C.60
  4. D.240
PastPaper.showAnswers

PastPaper.workedSolution

First, the binary pattern 0011 1100 represents the denary value \(32 + 16 + 8 + 4 = 60\). Alternatively, performing a logical right shift of 2 places shifts all bits two positions to the right, filling the left empty spaces with zeros, resulting in 0000 1111. Converting 0000 1111 to denary gives \(8 + 4 + 2 + 1 = 15\). Shifting right by 2 places is also mathematically equivalent to integer division by \(2^2 = 4\), so \(60 \div 4 = 15\).

PastPaper.markingScheme

1 mark for identifying the shifted binary pattern as 0000 1111 (or identifying the initial denary value as 60 and stating the division by 4 rule). 1 mark for correctly identifying Option A (15) as the final denary value.
PastPaper.question 2 · multiple_choice
2 PastPaper.marks
Which of the following application layer protocols is used to retrieve email messages from a mail server while synchronising changes across multiple devices?
  1. A.SMTP
  2. B.IMAP
  3. C.POP3
  4. D.HTTPS
PastPaper.showAnswers

PastPaper.workedSolution

IMAP (Internet Message Access Protocol) is designed to retrieve email messages from a mail server and automatically synchronises actions (such as marking an email as read or moving it to a folder) across multiple devices. POP3 does not synchronise changes back to the server, SMTP is used for sending emails, and HTTPS is used for secure web traffic.

PastPaper.markingScheme

1 mark for describing that IMAP allows synchronization across multiple clients. 1 mark for identifying Option B as the correct protocol.
PastPaper.question 3 · multiple_choice
2 PastPaper.marks
Consider the following expression written in Python style: result = (27 // 4) + (27 % 4). What is the value stored in the variable result?
  1. A.6
  2. B.8
  3. C.9
  4. D.11
PastPaper.showAnswers

PastPaper.workedSolution

The expression uses two arithmetic operators: integer division (//) and modulo (%). First, \(27 \text{ // } 4\) calculates the whole number of times 4 goes into 27, which is 6. Second, \(27 \text{ % } 4\) calculates the remainder of that division, which is 3. Adding these two results together yields \(6 + 3 = 9\).

PastPaper.markingScheme

1 mark for correctly evaluating both parts of the expression: integer division as 6 and modulo as 3. 1 mark for adding the two values to get 9 (Option C).
PastPaper.question 4 · multiple_choice
2 PastPaper.marks
A bitmap image has dimensions of 400 pixels by 300 pixels and uses a 4-bit colour depth. What is the minimum file size of this image in kilobytes (KB)? (Assume 1 KB = 1000 bytes)
  1. A.60 KB
  2. B.120 KB
  3. C.480 KB
  4. D.240 KB
PastPaper.showAnswers

PastPaper.workedSolution

To find the minimum file size: 1. Calculate the total number of pixels: \(400 \times 300 = 120,000\) pixels. 2. Calculate total bits by multiplying pixels by color depth: \(120,000 \times 4\text{ bits} = 480,000\text{ bits}\). 3. Convert bits to bytes by dividing by 8: \(480,000 \div 8 = 60,000\text{ bytes}\). 4. Convert bytes to kilobytes by dividing by 1000: \(60,000 \div 1000 = 60\text{ KB}\).

PastPaper.markingScheme

1 mark for showing a correct intermediate step (such as calculating 120,000 pixels or 60,000 bytes). 1 mark for identifying 60 KB (Option A) as the final correct size.
PastPaper.question 5 · multiple_choice
2 PastPaper.marks
An employee accesses a competitor's secure server without authorisation to inspect their secret pricing strategies, but does not copy, modify, or delete any files. Which UK legislation has been violated?
  1. A.Copyright, Designs and Patents Act 1988
  2. B.Freedom of Information Act 2000
  3. C.Data Protection Act 2018
  4. D.Computer Misuse Act 1990
PastPaper.showAnswers

PastPaper.workedSolution

The Computer Misuse Act 1990 makes it an offence to gain unauthorised access to computer material. Even though the employee did not modify or delete any files, the act of gaining unauthorised access itself constitutes a criminal offence under Section 1 of this Act.

PastPaper.markingScheme

1 mark for demonstrating knowledge that unauthorised access to any computer network constitutes a crime even without modification of data. 1 mark for identifying the Computer Misuse Act 1990 (Option D).
PastPaper.question 6 · multiple_choice
2 PastPaper.marks
A binary search algorithm is used to search for the number 18 in the sorted list [2, 5, 8, 12, 18, 23, 29]. How many comparisons are made to find the target number?
  1. A.1 comparison
  2. B.2 comparisons
  3. C.3 comparisons
  4. D.4 comparisons
PastPaper.showAnswers

PastPaper.workedSolution

1. The list has 7 elements, indexed 0 to 6. The midpoint index is \((0 + 6) \div 2 = 3\). The value at index 3 is 12. Compare 18 with 12. Since \(18 > 12\), we search the right sublist: [18, 23, 29] (indices 4 to 6). (Comparison 1) 2. The new midpoint index is \((4 + 6) \div 2 = 5\). The value at index 5 is 23. Compare 18 with 23. Since \(18 < 23\), we search the left sublist: [18] (indices 4 to 4). (Comparison 2) 3. The new midpoint index is \((4 + 4) \div 2 = 4\). The value at index 4 is 18. Compare 18 with 18. Match found. (Comparison 3) Total comparisons = 3.

PastPaper.markingScheme

1 mark for identifying the correct trace sequence of midpoint items checked (12, then 23, then 18). 1 mark for selecting Option C (3 comparisons).
PastPaper.question 7 · multiple_choice
2 PastPaper.marks
A hacker sets up a rogue wireless router in a public place with the same name as the local café's official network. Unsuspecting customers connect to it, allowing the hacker to monitor and capture their internet traffic. What is the name of this cyber attack?
  1. A.Shoulder surfing
  2. B.Denial of Service (DoS)
  3. C.Man-in-the-middle (MitM)
  4. D.Brute-force attack
PastPaper.showAnswers

PastPaper.workedSolution

This is a classic example of a Man-in-the-middle (MitM) attack. By inserting a rogue node (the fake wireless router) between the user and the actual internet, the attacker can silently capture, read, or modify messages passing between the two parties.

PastPaper.markingScheme

1 mark for recognizing that positioning an unauthorized entity to intercept communications between two hosts is a Man-in-the-middle attack. 1 mark for identifying Option C.
PastPaper.question 8 · multiple_choice
2 PastPaper.marks
A run-length encoding (RLE) algorithm is used to compress the following character string: AAAAABBBCCCCCCDD. What is the correct RLE compressed representation of this string if each run is represented by its frequency followed by the character?
  1. A.5A3B6C2D
  2. B.A5B3C6D2
  3. C.5A3B6C1D1D
  4. D.4A3B6C2D
PastPaper.showAnswers

PastPaper.workedSolution

The string consists of four consecutive runs of characters: 1. A run of five 'A's -> 5A. 2. A run of three 'B's -> 3B. 3. A run of six 'C's -> 6C. 4. A run of two 'D's -> 2D. Combining these gives '5A3B6C2D'.

PastPaper.markingScheme

1 mark for identifying the frequency of at least two of the runs (e.g. 5 'A's and 6 'C's). 1 mark for selecting the complete correct sequence 5A3B6C2D (Option A).
PastPaper.question 9 · Multiple Choice
2 PastPaper.marks
A student performs a logical shift right of 2 places on the 8-bit binary number 00111000. Identify the effect of this operation on the denary value and the resulting 8-bit binary pattern.
  1. A.The denary value is divided by 4. The resulting binary pattern is 00001110.
  2. B.The denary value is divided by 2. The resulting binary pattern is 00011100.
  3. C.The denary value is multiplied by 4. The resulting binary pattern is 11100000.
  4. D.The denary value is divided by 4. The resulting binary pattern is 00001100.
PastPaper.showAnswers

PastPaper.workedSolution

The original binary pattern 00111000 is 56 in denary. Performing a logical right shift of 2 places shifts all bits two positions to the right, filling the vacant left spaces with 0s, resulting in 00001110 (which is 14 in denary). Shifting right by 2 places is equivalent to integer division by \(2^2\) (which is 4). Since \(56 / 4 = 14\), this matches.

PastPaper.markingScheme

1 mark for identifying that a logical shift right of 2 places divides the value by 4. 1 mark for calculating the correct binary pattern of 00001110.
PastPaper.question 10 · Multiple Choice
2 PastPaper.marks
An IT technician is comparing the reliability of star and bus network topologies. Identify the statement that correctly describes the impact of a single cable break in these topologies.
  1. A.In a star topology, a break in any cable shuts down the entire network. In a bus topology, a break in any cable only affects the client connected to it.
  2. B.In a star topology, a break in a peripheral cable only disconnects that specific node. In a bus topology, a break in the central backbone cable splits the network, disrupting communication for multiple nodes.
  3. C.In a star topology, a break in a peripheral cable disconnects all nodes. In a bus topology, a break in the central backbone cable has no effect due to the terminators.
  4. D.In both topologies, a single cable break is automatically bypassed by the switches, resulting in zero network disruption.
PastPaper.showAnswers

PastPaper.workedSolution

In a star network, each device is connected to a central switch/hub via its own cable. A failure in one client's cable only affects that node. In a bus network, all devices share a single backbone cable. If this backbone cable is severed, the network is split and the bus structure is broken (loss of termination), causing the whole network to fail or split.

PastPaper.markingScheme

1 mark for identifying the correct impact of a cable break in a star topology (only one node affected). 1 mark for identifying the correct impact of a backbone cable break in a bus topology (disruption of multiple nodes/entire network).
PastPaper.question 11 · Multiple Choice
2 PastPaper.marks
A sequence of characters 'AAAAABBBCC' is compressed using Run-Length Encoding (RLE). The original text uses standard ASCII (8 bits per character). The RLE scheme uses 8 bits for the run count followed by 8 bits for the character. Identify the correct sizes and compression outcome.
  1. A.Original size is 80 bits. Compressed size is 48 bits. The file size is reduced by 32 bits.
  2. B.Original size is 80 bits. Compressed size is 24 bits. The file size is reduced by 56 bits.
  3. C.Original size is 80 bits. Compressed size is 48 bits. The file size is increased by 16 bits.
  4. D.Original size is 10 bits. Compressed size is 3 bits. The file size is reduced by 7 bits.
PastPaper.showAnswers

PastPaper.workedSolution

Original size: \(10 \times 8 = 80\) bits. The compressed RLE pairs are: (5, 'A'), (3, 'B'), and (2, 'C'). This is 3 pairs. Each pair takes 16 bits (8 bits count + 8 bits character), so \(3 \times 16 = 48\) bits. The reduction in size is \(80 - 48 = 32\) bits.

PastPaper.markingScheme

1 mark for calculating the correct original size (80 bits) and compressed size (48 bits). 1 mark for calculating the correct reduction in file size (32 bits).
PastPaper.question 12 · Multiple Choice
2 PastPaper.marks
A programmer needs to search for an item in a sorted list of 128 elements. Identify the maximum number of comparisons required to find the item (or determine it is not present) using a binary search compared to a linear search.
  1. A.Binary search requires a maximum of 8 comparisons; Linear search requires a maximum of 128 comparisons.
  2. B.Binary search requires a maximum of 7 comparisons; Linear search requires a maximum of 64 comparisons.
  3. C.Binary search requires a maximum of 128 comparisons; Linear search requires a maximum of 8 comparisons.
  4. D.Binary search requires a maximum of 16 comparisons; Linear search requires a maximum of 128 comparisons.
PastPaper.showAnswers

PastPaper.workedSolution

With binary search, the search space is halved at each step. For 128 items: \(128 \rightarrow 64 \rightarrow 32 \rightarrow 16 \rightarrow 8 \rightarrow 4 \rightarrow 2 \rightarrow 1\), which takes at most 8 comparisons to find any element or prove it is absent. For a linear search, the worst-case scenario is that the item is at the very end of the list or not in the list at all, requiring 128 comparisons.

PastPaper.markingScheme

1 mark for identifying that a binary search on 128 elements takes a maximum of 8 comparisons. 1 mark for identifying that linear search worst-case takes 128 comparisons.
PastPaper.question 13 · Multiple Choice
2 PastPaper.marks
During the fetch-decode-execute cycle, registers in the CPU are used to manage instruction retrieval. Identify the correct statement regarding the roles of the Program Counter (PC) and the Memory Address Register (MAR) during the fetch stage.
  1. A.The PC holds the current instruction being decoded, while the MAR holds the address of the next instruction and increments automatically.
  2. B.The PC holds the address of the next instruction to be fetched. This address is copied to the MAR, which points to the location in memory where the instruction is stored.
  3. C.The PC holds the intermediate data results from the ALU, while the MAR transfers instructions directly to the execution unit.
  4. D.The PC is updated only at the end of the entire program, while the MAR dynamically stores all decoded operational codes.
PastPaper.showAnswers

PastPaper.workedSolution

During the fetch stage, the address of the next instruction is held in the Program Counter (PC). This address is copied to the Memory Address Register (MAR), which is used to locate the instruction in RAM. The PC is then incremented to point to the next instruction.

PastPaper.markingScheme

1 mark for describing the role of the Program Counter (PC) in storing and providing the address of the next instruction. 1 mark for describing the role of the Memory Address Register (MAR) in holding the copied address to locate the instruction in memory.
PastPaper.question 14 · Multiple Choice
2 PastPaper.marks
A programmer writes a program with the following structure: global x = 20; subprogram update() local x = 5; print(x); endsubprogram; update(); print(x). Identify the printed output and the explanation of how scope affects the variables.
  1. A.Output: 5 followed by 20. The local variable 'x' exists only inside update() and does not affect the global variable 'x' outside the subprogram.
  2. B.Output: 5 followed by 5. The local variable 'x' overwrites the global variable permanently during the subprogram execution.
  3. C.Output: 20 followed by 20. The subprogram cannot modify or declare 'x' because a global variable with the same name already exists.
  4. D.Output: 5 followed by 25. The local variable 'x' is added to the global variable 'x' when the subprogram finishes.
PastPaper.showAnswers

PastPaper.workedSolution

The global variable 'x' is assigned 20. When update() is called, it creates a local variable 'x' and assigns it 5. Printing 'x' inside the subprogram prints the local value 5. After the subprogram ends, the local 'x' is destroyed. The subsequent print statement in the main program prints the global 'x', which remains 20.

PastPaper.markingScheme

1 mark for stating the correct output sequence (5 and 20). 1 mark for explaining that the local variable 'x' has a scope limited to the subprogram and does not overwrite the global variable's value.
PastPaper.question 15 · Multiple Choice
2 PastPaper.marks
Identify the correct pairing of cybersecurity threats for these two scenarios: Scenario 1: A user receives a deceptive email containing a link to a fake bank website designed to capture login credentials. Scenario 2: An unauthorized individual stands close to a user at an ATM to watch them enter their PIN.
  1. A.Scenario 1: Phishing; Scenario 2: Shoulder surfing.
  2. B.Scenario 1: Pharming; Scenario 2: Spyware.
  3. C.Scenario 1: Shoulder surfing; Scenario 2: Phishing.
  4. D.Scenario 1: Phishing; Scenario 2: Brute force attack.
PastPaper.showAnswers

PastPaper.workedSolution

Scenario 1 describes phishing, which is a form of social engineering where attackers masquerade as trustworthy entities in electronic communications to steal sensitive data. Scenario 2 describes shoulder surfing, where an attacker physically observes a user entering confidential information such as a PIN.

PastPaper.markingScheme

1 mark for correctly identifying Scenario 1 as phishing. 1 mark for correctly identifying Scenario 2 as shoulder surfing.
PastPaper.question 16 · Structured Explanation
2.5 PastPaper.marks
Describe how a packet filtering firewall protects a local area network (LAN) from unauthorized external access.
PastPaper.showAnswers

PastPaper.workedSolution

A packet filtering firewall works by examining the header of every incoming and outgoing data packet. It compares the details, such as the source IP address, destination IP address, and port numbers, against a set of predefined security rules. If a packet meets the criteria, it is allowed through; otherwise, it is blocked or dropped.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for stating that it inspects packet headers/data packets. 1 mark for explaining that it compares packet details against predefined security rules or policies. 0.5 mark for explaining that non-compliant packets are dropped or blocked to prevent unauthorized access.
PastPaper.question 17 · Structured Explanation
2.5 PastPaper.marks
Explain how run-length encoding (RLE) is used to compress image data, referencing how repeating sequences of pixels are represented.
PastPaper.showAnswers

PastPaper.workedSolution

RLE works by finding runs of consecutive identical data values (such as adjacent pixels of the same colour). It then replaces each run with a single copy of the value and a count of how many times it repeats. For example, a run of six red pixels is stored as 'Red, 6' rather than 'Red, Red, Red, Red, Red, Red', saving storage space.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for stating that it identifies contiguous/consecutive runs of identical data. 1 mark for explaining that it replaces these runs with a single data value and a count of its repetitions. 0.5 mark for explaining that this reduces storage requirements by removing redundant data.
PastPaper.question 18 · Structured Explanation
2.5 PastPaper.marks
Describe how analogue sound signals are converted into a digital format so that they can be processed by a computer.
PastPaper.showAnswers

PastPaper.workedSolution

The continuously varying analogue sound wave is converted to digital by sampling its amplitude at regular intervals. The value of each sample is rounded to the nearest available digital level (quantization) and represented as a binary number. These binary numbers are stored chronologically to build the digital representation.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for explaining that the amplitude of the analogue wave is sampled at regular time intervals. 1 mark for explaining that each measured amplitude is converted into a binary/digital value. 0.5 mark for explaining that these binary values are stored in sequence to represent the sound.
PastPaper.question 19 · Structured Explanation
2.5 PastPaper.marks
Describe how a phishing attack exploits human vulnerability to compromise computer systems.
PastPaper.showAnswers

PastPaper.workedSolution

Phishing relies on social engineering. Attackers create fake emails or messages designed to look like authentic communications from trusted organizations. These messages use psychological triggers, such as urgency or fear, to manipulate the recipient. This tricks the user into revealing login credentials, financial info, or downloading malware that infects the computer system.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for describing the creation/sending of fake messages designed to look authentic. 1 mark for explaining how it preys on human emotion/vulnerability (trust, fear, urgency) to manipulate actions. 0.5 mark for the outcome (stealing credentials, installing malware, or compromising security).
PastPaper.question 20 · Structured Explanation
2.5 PastPaper.marks
Explain how utility software defragments a magnetic hard disk drive (HDD) to improve system performance.
PastPaper.showAnswers

PastPaper.workedSolution

As files are created, deleted, and modified, they become fragmented, meaning parts of a single file are stored in separate, non-adjacent physical sectors on the magnetic disk. Defragmentation utility software reorganizes the data on the drive by moving the fragments of each file so that they are stored in contiguous sectors. It also pools free space. This reduces the mechanical movement of the read/write arm, speeding up data retrieval times.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for identifying that files become split/fragmented over time and stored in non-contiguous sectors. 1 mark for explaining that defragmentation moves files and their parts so they are stored continuously/adjacently. 0.5 mark for explaining how this speeds up file read/write times by reducing physical movement of the drive head.
PastPaper.question 21 · Structured Explanation
2.5 PastPaper.marks
Describe the specific role of the Program Counter (PC) register during the fetch stage of the fetch-decode-execute cycle.
PastPaper.showAnswers

PastPaper.workedSolution

At the start of the fetch stage, the Program Counter (PC) holds the memory address of the next instruction that needs to be executed. This address is sent over the address bus to the Memory Address Register (MAR). Immediately after this, the PC is incremented by 1 so that it holds the address of the next instruction in sequence, preparing for the next cycle.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for stating that the PC holds the address of the next instruction to be retrieved. 1 mark for explaining that this address is copied to the Memory Address Register (MAR). 0.5 mark for explaining that the PC is incremented so it points to the next sequential instruction.
PastPaper.question 22 · Structured Explanation
2.5 PastPaper.marks
Describe how a binary search algorithm locates a target item within a sorted list.
PastPaper.showAnswers

PastPaper.workedSolution

The binary search algorithm starts by identifying the midpoint of the sorted list. It compares the value at this midpoint with the target value. If they match, the search is successful. If the target is smaller than the midpoint value, the search continues in the left half, discarding the right half. If the target is larger, it continues in the right half, discarding the left. This process of halving and comparing repeats until the item is found or there are no items left to search.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for identifying the middle item and comparing it to the target. 1 mark for explaining that the list is divided in half, discarding the irrelevant half. 0.5 mark for explaining the iterative/recursive nature of repeating this step on the remaining subset.
PastPaper.question 23 · Structured Explanation
2.5 PastPaper.marks
Explain the main differences between open-source software and proprietary software in terms of licensing and code access.
PastPaper.showAnswers

PastPaper.workedSolution

Open-source software licensing allows users free access to the source code, meaning they can modify, customize, and redistribute the software openly. Proprietary software is closed-source, meaning the owner restricts access to the source code. Users only get the compiled executable file and must purchase a license that legally forbids copying, modifying, or sharing the software.

PastPaper.markingScheme

Award up to 2.5 marks: 1 mark for explaining that open-source allows access to the raw source code for modification/distribution. 1 mark for explaining that proprietary software keeps the source code compiled/hidden (closed-source) and restricts modifications. 0.5 mark for contrasting the licensing terms (e.g. proprietary usually requires a fee/restrictive license, open-source has permissive licenses).
PastPaper.question 24 · Structured Explanation
3 PastPaper.marks
Explain how Run-Length Encoding (RLE) can be used to compress the data representing a simple black-and-white bitmap image.
PastPaper.showAnswers

PastPaper.workedSolution

Run-Length Encoding (RLE) compresses the image by identifying consecutive pixels of the same colour, known as runs. Instead of storing each individual pixel separately, RLE stores the count of consecutive pixels followed by the colour value (for example, representing five consecutive black pixels as 5B). This reduces the file size because fewer data elements are stored for repeated data.

PastPaper.markingScheme

Award up to 3 marks for a clear explanation: 1 mark for identifying that RLE detects runs of consecutive pixels of the same colour/value. 1 mark for explaining that it stores the count of the pixels followed by the colour/value. 1 mark for explaining that this reduces the number of data values stored, thus reducing overall file size.
PastPaper.question 25 · Structured Explanation
2 PastPaper.marks
Explain how a firewall protects a local area network (LAN) from unauthorized external access.
PastPaper.showAnswers

PastPaper.workedSolution

A firewall acts as a barrier that monitors all incoming and outgoing network traffic. It inspects packets of data against a set of pre-defined security rules, blocking any packets that do not meet these criteria while allowing authorized traffic to pass.

PastPaper.markingScheme

Award up to 2 marks for a clear explanation: 1 mark for stating that the firewall monitors/inspects all incoming and outgoing network packets. 1 mark for explaining that it applies a set of pre-defined security rules/rulesets to allow or block the traffic.
PastPaper.question 26 · Algorithmic Representation & Flowcharting
6 PastPaper.marks
A programmer is designing an algorithm to filter sensor data. The algorithm processes an array of 4 integers named numbers.

Here is the flowchart description:
1. Start
2. Set index to 0
3. Set count to 0
4. Is index < 4?
- If NO: Output count and Stop.
- If YES:
- Set num to numbers[index]
- Is num > 0 AND (num MOD 2) == 0?
- If YES: Set count to count + 1
- If NO: Do nothing
- Set index to index + 1
- Loop back to step 4.

Complete the trace table below for the input array: numbers = [4, -3, 8, 0]. Note that some steps may not change all variables.

| Row | index | num | num > 0 AND (num MOD 2) == 0 (True/False) | count | Output |
|---|---|---|---|---|---|
| Initial | 0 | - | - | 0 | - |
| 1 | | | | | |
| 2 | | | | | |
| 3 | | | | | |
| 4 | | | | | |
| Final | | - | - | | |
PastPaper.showAnswers

PastPaper.workedSolution

Let's trace the execution of the flowchart step by step with numbers = [4, -3, 8, 0]:

- **Initial State**: index = 0, count = 0.
- **First Loop (index = 0)**:
- index < 4 is True.
- num = numbers[0] = 4.
- Condition 'num > 0 AND (num MOD 2) == 0' checks if 4 > 0 (True) AND 4 % 2 == 0 (True), which evaluates to True.
- count is incremented to 1.
- index is incremented to 1.
- **Second Loop (index = 1)**:
- index < 4 is True.
- num = numbers[1] = -3.
- Condition '-3 > 0' is False, so the condition evaluates to False.
- count remains 1.
- index is incremented to 2.
- **Third Loop (index = 2)**:
- index < 4 is True.
- num = numbers[2] = 8.
- Condition '8 > 0' (True) AND '8 MOD 2 == 0' (True) evaluates to True.
- count is incremented to 2.
- index is incremented to 3.
- **Fourth Loop (index = 3)**:
- index < 4 is True.
- num = numbers[3] = 0.
- Condition '0 > 0' is False, so the overall condition evaluates to False.
- count remains 2.
- index is incremented to 4.
- **Fifth Loop Check (index = 4)**:
- index < 4 is False.
- Output is count (2).
- Execution stops.

PastPaper.markingScheme

Award 1 mark per correct row state sequence (up to 6 marks total):
- Row 1: index = 0, num = 4, Condition = True, count = 1 [1 Mark]
- Row 2: index = 1, num = -3, Condition = False, count = 1 [1 Mark]
- Row 3: index = 2, num = 8, Condition = True, count = 2 [1 Mark]
- Row 4: index = 3, num = 0, Condition = False, count = 2 [1 Mark]
- Final Row (index): index changes to 4 [1 Mark]
- Final Row (Output): Output evaluates to 2 [1 Mark]
PastPaper.question 27 · Algorithmic Representation & Flowcharting
6 PastPaper.marks
A flowchart for a automated climate-control system has the following steps:

1. Input the current temperature (currentTemp) and the target temperature (targetTemp).
2. If currentTemp is less than targetTemp - 2, set heaterStatus to "ON" and coolerStatus to "OFF".
3. Else, if currentTemp is greater than targetTemp + 2, set heaterStatus to "OFF" and coolerStatus to "ON".
4. Otherwise, set both heaterStatus and coolerStatus to "OFF".
5. Output heaterStatus and coolerStatus.

Translate this flowchart logic into Edexcel GCSE-style pseudocode.
PastPaper.showAnswers

PastPaper.workedSolution

To convert the flowchart logical steps into Edexcel-style pseudocode:
1. Input statements use `RECEIVE ... FROM KEYBOARD`.
2. Comparison logic uses `IF ... THEN`.
3. The sub-checks use `ELSE IF ... THEN` and default values are placed under `ELSE`.
4. Variable assignment is structured as `SET ... TO ...` or via direct assignment `= `.
5. Output statements use `SEND ... TO DISPLAY`.

PastPaper.markingScheme

- 1 mark for correct receipt of inputs using RECEIVE (both currentTemp and targetTemp).
- 1 mark for correct structure of the first conditional check (IF currentTemp < targetTemp - 2 THEN).
- 1 mark for correct updates to heaterStatus and coolerStatus inside the first IF branch.
- 1 mark for correct structure of the ELSE IF branch checking (currentTemp > targetTemp + 2).
- 1 mark for correct default assignments inside the ELSE block.
- 1 mark for displaying the outputs using SEND.
PastPaper.question 28 · Algorithmic Representation & Flowcharting
6 PastPaper.marks
An analyst has drafted a flowchart algorithm designed to calculate the average of a series of positive integers.

The algorithm operates as follows:
- Initialize `total` to 0 and `count` to 0.
- Prompt and input `num` from the user.
- Loop while `num != -1` (where -1 is the sentinel value to exit).
- Inside the loop: add `num` to `total`, add 1 to `count`, and prompt and input next `num`.
- After the loop: calculate `average = total / count`.
- Output `average`.

a) State the conditions under which this flowchart will cause a critical runtime division-by-zero error. (2 marks)

b) Describe how the flowchart logic can be modified to make it robust against this error, explaining any decisions or outputs that need to be added. (4 marks)
PastPaper.showAnswers

PastPaper.workedSolution

a) If the first value entered is -1, the loop condition `num != -1` evaluates to False immediately. The loop body never runs, leaving `count` initialized at 0. The program then executes `average = total / count`, which translates to `0 / 0`, causing a fatal crash.

b) The algorithm must verify that records were processed before attempting division.
1. Before calculating `average = total / count`, insert a decision box: `Is count > 0?` (or `Is count == 0?`).
2. If `count > 0` is True, execute the division `average = total / count` and output the result.
3. If `count > 0` is False, output a fallback message such as "No items entered" instead of performing the calculation.
4. Both paths should then direct flow to the End terminal.

PastPaper.markingScheme

Part a (2 marks):
- 1 mark for identifying the scenario: when the first input is -1 / the loop never executes.
- 1 mark for explaining the exact variable state: 'count' remains 0, leading to a division-by-zero math error.

Part b (4 marks):
- 1 mark for stating that a selection/decision box needs to be added before the calculation step.
- 1 mark for defining the correct condition to check (e.g. `count > 0` or `count == 0` or `count != 0`).
- 1 mark for describing the 'Yes' / True branch (calculate and output the average).
- 1 mark for describing the 'No' / False branch (print an error/warning message and avoid division).
PastPaper.question 29 · Extended Discussion Essay
6 PastPaper.marks
A local council plans to replace its traditional physical library service with a fully automated digital lending hub. The physical library building will be closed. Users will access e-books and digital resources via an app, or use automated touchscreen kiosks at a small unstaffed booth to borrow a limited number of physical items.

Discuss the ethical and cultural impacts of this digital transformation on the local community. Your response should consider both benefits and drawbacks.
PastPaper.showAnswers

PastPaper.workedSolution

### Indicative Content

**Ethical & Cultural Benefits (Pros):**
* **Accessibility & Convenience:** 24/7 access to digital books from home for those with internet connections, particularly beneficial for users with mobility issues who struggle to visit physical libraries during limited opening hours.
* **Broader Catalog:** Digital systems can offer access to a wider variety of e-books, audiobooks, and multi-language digital media without the limitations of physical shelf-space.
* **Digital Literacy:** Encourages members of the community to learn and adopt new digital skills and technologies.
* **Reallocation of Resources:** Saved funds from building maintenance and staffing could be reallocated to other public services or used to subsidise digital access initiatives.

**Ethical & Cultural Drawbacks (Cons):**
* **Digital Divide and Exclusion:** Vulnerable groups, low-income families, or elderly residents who lack reliable internet access, smartphones, or tablets may be entirely excluded from accessing library resources.
* **Loss of Community Hub:** Traditional libraries act as safe, warm, and social spaces for community groups, children's story hours, and lonely or vulnerable individuals. Closing the physical space removes this social cohesion.
* **Job Losses:** Physical librarians and support staff will lose their livelihoods or need to retrain. This also removes human 'expertise' and personalised reading recommendations.
* **Privacy and Data Concerns:** Digital platforms track reading habits, logins, and search histories. Users may have ethical concerns about their personal data being processed by third-party private platform providers.

PastPaper.markingScheme

For 6-mark extended writing questions, Pearson Edexcel uses a level-based marking grid:

* **Level 1 (1-2 marks):** Identifies basic or isolated points. Response lacks depth and structure. Limited application of computer science concepts (ethics/culture) to the scenario.
* **Level 2 (3-4 marks):** Demonstrates some understanding and discussion of both positive and negative impacts. Explanations are reasonable but may lack complete clarity, balance, or detail.
* **Level 3 (5-6 marks):** Shows a thorough, well-structured, and balanced discussion of both benefits and drawbacks. Clear and mature understanding of the ethical and cultural implications (e.g., digital divide, social hub, job losses vs. accessibility). Consistent technical accuracy and logical progression of arguments.
PastPaper.question 30 · Extended Discussion Essay
6 PastPaper.marks
A local council plans to replace its traditional physical library service with a fully automated digital lending hub. The physical library building will be closed. Users will access e-books and digital resources via an app, or use automated touchscreen kiosks at a small unstaffed kiosk booth to borrow a limited number of physical items.

Discuss the ethical and cultural impacts of this digital transformation on the local community. Your response should consider both benefits and drawbacks.
PastPaper.showAnswers

PastPaper.workedSolution

### Indicative Content

**Ethical & Cultural Benefits (Pros):**
* **Accessibility & Convenience:** 24/7 access to digital books from home for those with internet connections, particularly beneficial for users with mobility issues who struggle to visit physical libraries during limited opening hours.
* **Broader Catalog:** Digital systems can offer access to a wider variety of e-books, audiobooks, and multi-language digital media without the limitations of physical shelf-space.
* **Digital Literacy:** Encourages members of the community to learn and adopt new digital skills and technologies.
* **Reallocation of Resources:** Saved funds from building maintenance and staffing could be reallocated to other public services or used to subsidise digital access initiatives.

**Ethical & Cultural Drawbacks (Cons):**
* **Digital Divide and Exclusion:** Vulnerable groups, low-income families, or elderly residents who lack reliable internet access, smartphones, or tablets may be entirely excluded from accessing library resources.
* **Loss of Community Hub:** Traditional libraries act as safe, warm, and social spaces for community groups, children's story hours, and lonely or vulnerable individuals. Closing the physical space removes this social cohesion.
* **Job Losses:** Physical librarians and support staff will lose their livelihoods or need to retrain. This also removes human 'expertise' and personalised reading recommendations.
* **Privacy and Data Concerns:** Digital platforms track reading habits, logins, and search histories. Users may have ethical concerns about their personal data being processed by third-party private platform providers.

PastPaper.markingScheme

For 6-mark extended writing questions, Pearson Edexcel uses a level-based marking grid:

* **Level 1 (1-2 marks):** Identifies basic or isolated points. Response lacks depth and structure. Limited application of computer science concepts (ethics/culture) to the scenario.
* **Level 2 (3-4 marks):** Demonstrates some understanding and discussion of both positive and negative impacts. Explanations are reasonable but may lack complete clarity, balance, or detail.
* **Level 3 (5-6 marks):** Shows a thorough, well-structured, and balanced discussion of both benefits and drawbacks. Clear and mature understanding of the ethical and cultural implications (e.g., digital divide, social hub, job losses vs. accessibility). Consistent technical accuracy and logical progression of arguments.

Paper 2: Application of Computational Thinking

Complete the tasks on your workstation using the provided python template files. Save files into the COMPLETED CODING folder.
7 PastPaper.question · 90 PastPaper.marks
PastPaper.question 1 · Basic Program Editing & Verification
10 PastPaper.marks
Complete the tasks on your workstation using the provided Python template files. Save files into the COMPLETED CODING folder.

A programmer has written a Python function to count how many passwords in a list are valid. A password is valid if it is at least 8 characters long AND contains at least one digit.

The programmer's attempt contains three errors.

Here is the buggy template code:
```python
def check_passwords(password_list):
valid_passwords = 0
for pwd in password_list
has_digit = False
if len(pwd) > 8:
for char in pwd:
if char.isdigit():
has_digit = True
if has_digit = True:
valid_passwords = valid_passwords + 1
return valid_passwords
```

Correct the errors to ensure the function works as intended.
PastPaper.showAnswers

PastPaper.workedSolution

The three errors in the original code are:
1. A missing colon at the end of the `for` loop header on line 3: `for pwd in password_list` should be `for pwd in password_list:`.
2. An incorrect comparison operator for checking length on line 5: `len(pwd) > 8` checks if the password has more than 8 characters, which excludes passwords of exactly 8 characters. It must be updated to `len(pwd) >= 8`.
3. A syntax error inside the `if` statement on line 10: `if has_digit = True:` uses a single equals sign (assignment) instead of double equals (comparison) or simply checking the boolean value directly. It must be corrected to `if has_digit == True:` or `if has_digit:`.

PastPaper.markingScheme

Award marks up to a maximum of 10:
- 2 marks: Correcting the syntax error on line 3 by adding the missing colon (`for pwd in password_list:`)
- 3 marks: Correcting the logical error on line 5 by changing the operator from `>` to `>=` to include passwords of exactly 8 characters
- 3 marks: Correcting the syntax/logical error on line 10 by changing `=` to `==` (or omitting `== True` entirely)
- 2 marks: Ensuring the overall program structure is syntactically sound and correctly returns the final integer variable `valid_passwords`.
PastPaper.question 2 · Basic Program Editing & Verification
10 PastPaper.marks
Complete the tasks on your workstation using the provided Python template files. Save files into the COMPLETED CODING folder.

A programmer wants to calculate the average score from a list of integer scores. The list can contain a value of -1, which represents an absent student. These -1 values must be ignored when calculating the average score. If there are no valid scores in the list (or the list is empty), the program must return 0.0 to prevent a division error.

The programmer's attempt contains three errors.

Here is the buggy template code:
```python
def calculate_average(scores):
total = 0
count = 0
for i in range(len(scores)):
score = scores[i]
if score != -1:
total = total + score
count = count + 1
average = total / count
return average
```

Correct the errors to ensure the function works as intended.
PastPaper.showAnswers

PastPaper.workedSolution

The three errors in the original code are:
1. The count variable increment (`count = count + 1`) is placed outside the `if score != -1:` block, meaning it increments for all elements including -1. It must be moved inside the `if` block.
2. There is no check to handle cases where there are no valid scores in the list. This leads to a `ZeroDivisionError` when computing `total / count`. A check `if count == 0: return 0.0` must be added.
3. Without the count safety check, the division operation fails under edge cases. Adding the check resolves both the division and the return-value requirement.

PastPaper.markingScheme

Award marks up to a maximum of 10:
- 3 marks: Correctly indenting `count = count + 1` so that it is nested inside the `if score != -1:` statement.
- 4 marks: Adding an conditional block to check if `count` is equal to 0, returning `0.0` immediately if so.
- 3 marks: Computing and returning the average correctly as a float division when count is greater than 0.
PastPaper.question 3 · Basic Program Editing & Verification
10 PastPaper.marks
Complete the tasks on your workstation using the provided Python template files. Save files into the COMPLETED CODING folder.

A programmer wants to write a function that performs a linear search on a list of names. The function must return the index of the first occurrence of the target name. If the target name is not in the list, it must return -1. For efficiency, the function should stop searching as soon as the target name is found.

The programmer's attempt contains three errors.

Here is the buggy template code:
```python
def linear_search(names_list, target):
found_index = -1
for i in range(1, len(names_list)):
if names_list == target:
found_index = i
return found_index
```

Correct the errors to ensure the function works as intended and is efficient.
PastPaper.showAnswers

PastPaper.workedSolution

The three errors in the original code are:
1. The loop starts at index 1 (`range(1, len(names_list))`), which misses the first element of the list at index 0. The range must start at index 0 or simply use `range(len(names_list))`.
2. The comparison `names_list == target` compares the entire list to the target string instead of comparing the individual element `names_list[i]`. This must be corrected to `names_list[i] == target`.
3. The loop does not stop searching when the target is found, which is inefficient and would overwrite the first occurrence if duplicates exist. Returning `i` immediately or using `break` fixes this problem.

PastPaper.markingScheme

Award marks up to a maximum of 10:
- 3 marks: Correcting the starting index of the loop range to ensure the entire list (starting from index 0) is checked.
- 3 marks: Correcting the comparison to extract and compare the individual element of the list (`names_list[i]`) rather than the list itself.
- 4 marks: Implementing an efficient exit strategy (e.g., immediate `return i` inside the conditional block, or updating `found_index` and executing a `break`).
PastPaper.question 4 · Algorithmic Line Reordering
15 PastPaper.marks
An incomplete and scrambled Python function is designed to calculate and return the average score of all passing marks (scores of 50 or above) from a list of integers called 'scores'. If there are no passing marks, the average must be set to 0 to prevent a division-by-zero error.

Here are the scrambled lines of Python code, with their original indentation preserved:

Line A: if score >= 50:
Line B: def analyse_scores(scores):
Line C: if count_pass == 0:
Line D: total_pass = 0
Line E: for score in scores:
Line F: total_pass = total_pass + score
Line G: return average
Line H: count_pass = 0
Line I: count_pass = count_pass + 1
Line J: else:
Line K: average = 0
Line L: average = total_pass / count_pass

Reorder the letters (A to L) to form the correct sequence of the function. State the final sequence as a comma-separated list of letters (e.g., B, D, H, ...).
PastPaper.showAnswers

PastPaper.workedSolution

To construct the correct Python function, we must follow a logical algorithm sequence:

1. First, we define the subprogram using the function header:
- Line B: def analyse_scores(scores):

2. Next, we must initialize our accumulator for the sum of passing scores and our counter for the number of passing scores before the loop starts:
- Line D: total_pass = 0
- Line H: count_pass = 0
(The order of D and H can be swapped without changing the outcome.)

3. We iterate through each element in the input list:
- Line E: for score in scores:

4. Inside the loop, we check if the score is a passing mark (greater than or equal to 50):
- Line A: if score >= 50:

5. If the condition is met, we add the score to the accumulator and increment the count:
- Line F: total_pass = total_pass + score
- Line I: count_pass = count_pass + 1
(The order of F and I can be swapped.)

6. Once the loop has finished, we must guard against division by zero. We check if count_pass is equal to 0:
- Line C: if count_pass == 0:

7. If count_pass is 0, we set the average to 0:
- Line K: average = 0

8. Otherwise, we calculate the average by dividing the total passing marks by the count:
- Line J: else:
- Line L: average = total_pass / count_pass

9. Finally, the function returns the calculated average:
- Line G: return average

Therefore, the correct sequence is:
B, D, H, E, A, F, I, C, K, J, L, G (or B, H, D, E, A, I, F, C, K, J, L, G).

PastPaper.markingScheme

Award up to 15 marks as follows:

- [1 mark] Correct placement of the function header (Line B) as the first line.
- [2 marks] Correct placement and initialization of both total_pass (Line D) and count_pass (Line H) immediately after the function header (either order).
- [2 marks] Correct placement of the 'for' loop header (Line E) followed by the condition checking if the score >= 50 (Line A).
- [2 marks] Correct placement and nesting of the accumulator and counter increment statements (Lines F and I) within the conditional structure of the loop (either order).
- [2 marks] Correct placement of the conditional check to avoid division by zero (Line C) after exiting the loop block.
- [2 marks] Correct placement of the base case assignment average = 0 (Line K) inside the true branch of the zero-count guard.
- [2 marks] Correct placement of the 'else' block (Line J) and average division calculation (Line L).
- [2 marks] Correct placement of the final return statement (Line G) as the last line of the function.
PastPaper.question 5 · File I/O Implementation
15 PastPaper.marks
Complete the tasks on your workstation using the provided python template files. Save files into the COMPLETED CODING folder.

A text file named `scores.txt` contains student names and two test scores. Each line of the file represents one student in the following comma-separated format:
`Name,Score1,Score2`

For example:
`Anusha,75,82`
`Bob,45,55`
`Charlie,90,88`

Write a Python program that:
1. Opens and reads the file `scores.txt`.
2. Uses exception handling (`try...except`) to catch a `FileNotFoundError` if the file does not exist, displaying the error message: `"Error: scores.txt not found"`.
3. Calculates the average (mean) score for each student.
4. Identifies students who have an average score of 70 or above.
5. Writes the names and average scores of these high-achieving students to a new file named `high_achievers.txt`. Each line in the new file must be written in the format:
`Name: Average` (with the average rounded to 1 decimal place, e.g., `Anusha: 78.5`).
6. Counts and returns the total number of high-achieving students written to the file.

An incomplete template `Q06_Template.py` is provided below:

```python
def process_scores():
# Write your code here
pass
```
PastPaper.showAnswers

PastPaper.workedSolution

```python
def process_scores():
count = 0
try:
with open(\"scores.txt\", \"r\") as infile, open(\"high_achievers.txt\", \"w\") as outfile:
for line in infile:
if line.strip():
parts = line.strip().split(\",\")
name = parts[0]
score1 = float(parts[1])
score2 = float(parts[2])
average = (score1 + score2) / 2
if average >= 70:
outfile.write(name + \": \" + str(round(average, 1)) + \"\
\")
count += 1
return count
except FileNotFoundError:
print(\"Error: scores.txt not found\")
return 0
```

PastPaper.markingScheme

Award 1 mark for each of the following up to a maximum of 15 marks:

* Handling Exceptions (3 Marks):
* Award 1 mark for using a `try...except` structural block.
* Award 1 mark for specifically catching `FileNotFoundError`.
* Award 1 mark for printing the exact message `"Error: scores.txt not found"` on exception.

* File Operations (2 Marks):
* Award 1 mark for opening `scores.txt` in read mode.
* Award 1 mark for opening `high_achievers.txt` in write mode (accept append mode if logic is correct).

* Reading and Parsing Data (3 Marks):
* Award 1 mark for iterating through each line of the input file.
* Award 1 mark for removing trailing whitespace or newline characters from the line (e.g., using `.strip()`).
* Award 1 mark for splitting each line using a comma delimiter (e.g., using `.split(',')`).

* Calculations and Processing (4 Marks):
* Award 1 mark for casting both score strings to numeric data types (integer or float).
* Award 1 mark for correctly calculating the average of the two scores.
* Award 1 mark for implementing a conditional statement checking if the average is >= 70.
* Award 1 mark for rounding the average to 1 decimal place (or formatting it to 1 decimal place).

* Writing and Output (3 Marks):
* Award 1 mark for writing the student's name and average score to `high_achievers.txt` in the format `Name: Average` followed by a newline.
* Award 1 mark for maintaining an accurate count of high-achieving students.
* Award 1 mark for returning the integer count at the end of the function execution.
PastPaper.question 6 · Sequential Search
15 PastPaper.marks
A developer is writing a program to help users find specific laptops from a collection. The collection is represented as a 2D list where each inner list represents a laptop containing: [Model, OS, RAM, Price]. For example: [['Model A', 'Windows', 8, 450], ['Model B', 'macOS', 16, 1200], ['Model C', 'Windows', 16, 750]]. You are required to write a Python function named find_laptops(laptop_list, os_criteria, max_price) that performs a sequential search on laptop_list. The function must: 1. Initialize an empty list to store the results. 2. Loop through each laptop in laptop_list. 3. Check if the laptop's OS matches os_criteria (exact match) AND the laptop's price is less than or equal to max_price. 4. If both conditions are met, append a new list containing the model name and the price, in the format [Model, Price], to the results list. 5. Return the completed results list. If no matching laptops are found, or if the input list is empty, the function must return an empty list.
PastPaper.showAnswers

PastPaper.workedSolution

A complete and correct Python function to perform this sequential search is: def find_laptops(laptop_list, os_criteria, max_price): results = [] for laptop in laptop_list: if laptop[1] == os_criteria and laptop[3] <= max_price: results.append([laptop[0], laptop[3]]) return results

PastPaper.markingScheme

Award marks as follows: [Structure & Parameters: 2 marks] - 1 mark for correct function header: def find_laptops(laptop_list, os_criteria, max_price). - 1 mark for returning the results list at the end. [Initialization: 2 marks] - 1 mark for initializing an empty results list: results = []. - 1 mark for handling empty inputs without throwing errors. [Looping: 3 marks] - 1 mark for using a loop (e.g. for loop) to iterate through laptop_list. - 2 marks for correctly accessing each individual sublist in the 2D array. [Filtering Conditions: 5 marks] - 1 mark for accessing OS at index 1. - 1 mark for comparing OS to os_criteria using exact equality (==). - 1 mark for accessing Price at index 3. - 1 mark for comparing Price to max_price using less-than-or-equal-to (<=). - 1 mark for using the logical 'and' operator to combine the constraints. [Populating Results: 3 marks] - 2 marks for appending a new list containing model (index 0) and price (index 3) to the results list. - 1 mark for only appending when BOTH conditions are successfully met.
PastPaper.question 7 · Sequential Search
15 PastPaper.marks
A developer is writing a program to help users find specific laptops from a collection. The collection is represented as a 2D list where each inner list represents a laptop containing: [Model, OS, RAM, Price]. For example: [['Model A', 'Windows', 8, 450], ['Model B', 'macOS', 16, 1200], ['Model C', 'Windows', 16, 750]]. You are required to write a Python function named find_laptops(laptop_list, os_criteria, max_price) that performs a sequential search on laptop_list. The function must: 1. Initialize an empty list to store the results. 2. Loop through each laptop in laptop_list. 3. Check if the laptop's OS matches os_criteria (exact match) AND the laptop's price is less than or equal to max_price. 4. If both conditions are met, append a new list containing the model name and the price, in the format [Model, Price], to the results list. 5. Return the completed results list. If no matching laptops are found, or if the input list is empty, the function must return an empty list.
PastPaper.showAnswers

PastPaper.workedSolution

A complete and correct Python function to perform this sequential search is: def find_laptops(laptop_list, os_criteria, max_price): results = [] for laptop in laptop_list: if laptop[1] == os_criteria and laptop[3] <= max_price: results.append([laptop[0], laptop[3]]) return results

PastPaper.markingScheme

Award marks as follows: [Structure & Parameters: 2 marks] - 1 mark for correct function header: def find_laptops(laptop_list, os_criteria, max_price). - 1 mark for returning the results list at the end. [Initialization: 2 marks] - 1 mark for initializing an empty results list: results = []. - 1 mark for handling empty inputs without throwing errors. [Looping: 3 marks] - 1 mark for using a loop (e.g. for loop) to iterate through laptop_list. - 2 marks for correctly accessing each individual sublist in the 2D array. [Filtering Conditions: 5 marks] - 1 mark for accessing OS at index 1. - 1 mark for comparing OS to os_criteria using exact equality (==). - 1 mark for accessing Price at index 3. - 1 mark for comparing Price to max_price using less-than-or-equal-to (<=). - 1 mark for using the logical 'and' operator to combine the constraints. [Populating Results: 3 marks] - 2 marks for appending a new list containing model (index 0) and price (index 3) to the results list. - 1 mark for only appending when BOTH conditions are successfully met.

PastPaper.sampleCTATitle

PastPaper.sampleCTADescription

PastPaper.sampleStickyMessage

PastPaper.stickyCtaText