Edexcel IGCSE Computer Science Theory & Practical
Theory notes for all six topics, plus Paper 2 Python practice β writing, debugging, algorithms, pseudocode and trace tables. Topic 1 is free β sign in with Google to unlock Topics 2β6 and the Practical sections.
Exam map: Paper 1 β 2 h Β· 80 marks Β· 50% (written exam) Β· Paper 2 β 3 h Β· 80 marks Β· 50% (practical exam on a computer, Python) Β· Grading 9β1 Β· Exam target: May/June 2027
Edexcel 4CP0 Β· Notes by Tr. Wai Lin Htet
How a computer sees a number
Tap the bits. Turn them on and off and watch the value change.
- Denary
- 65
- Hex
- 41
- ASCII character
- A
Try it before you sign in
No sign-in needed for these β two video lessons and a sample from two topics, so you can see how the notes teach before you join.
Python Basics β Day 2
Pseudocode sample
FOR Index β 1 TO 5
IF Names[Index] = "Aung" THEN
OUTPUT "Found at position ", Index
ENDIF
NEXT Index
Python Basics sample
name = input("Name: ")
age = int(input("Age: "))
print("Hello", name)
print("Next year you will be", age + 1)
Topic list
Six topics and four Paper 2 practical sections, in one combined page. Topic 1 is free to read β sign in with Google to unlock Topics 2β6 and the Practical sections.
Paper 1 Β· Principles of Computer Science
Paper 2 Β· Application of Computational Thinking
How to get access
1) Sign in with Google on the login page. 2) Your teacher approves your account. 3) Your courses appear on your dashboard β open this page from there.
Paper 1 Β· Principles of Computer Science
Theory notes for Topics 1 to 6. Each topic follows the syllabus order and ends with practice questions and model answers.
Problem Solving
What an algorithm is, how to break a problem down, and the four standard algorithms you must know: linear search, binary search, bubble sort and merge sort.
1.1Algorithms, decomposition and abstraction
An algorithm is a set of precise, ordered steps that solves a problem or completes a task. A good algorithm is clear enough for someone (or a computer) to follow exactly, it always finishes, and it gives the correct answer for every allowed input.
Before you write any code, break the problem down:
- Decomposition
- Splitting a big problem into smaller sub-problems, each of which is easier to solve. For example, "build a quiz program" splits into: read the questions, ask each question, check the answer, keep the score, show the result.
- Abstraction
- Ignoring details that do not matter for the problem, and keeping only what is needed. A bus timetable app needs the route and the time; it does not need the colour of the bus.
- Algorithmic thinking
- Turning the sub-problems into a clear sequence of steps, in the right order, with decisions (selection) and repeats (iteration) where needed.
Algorithms are written as pseudocode or drawn as flowcharts before they are coded. Pseudocode uses plain English words with a fixed structure, so it is easy to read and easy to turn into any programming language.
First pseudocode
These are the words you will use again and again: DECLARE to name a variable, β to give it a value, INPUT to read a value, OUTPUT to show one, and IF β¦ THEN β¦ ENDIF to make a decision.
DECLARE Height : INTEGER
INPUT Height
IF Height >= 170 THEN
OUTPUT "Tall"
ENDIF
β means "gets the value of" β it is not an equals sign. Total β Total + 5 means "take the current value of Total, add 5, and store the result back in Total". Writing = instead of β loses marks.1.2Searching
Linear search
A linear search checks each item in turn, from the first to the last, until it finds the target or reaches the end. It works on any list β sorted or not.
FOR Index β 1 TO 5
IF Names[Index] = "Aung" THEN
OUTPUT "Found at position ", Index
ENDIF
NEXT Index
With n items, a linear search makes at most n comparisons. If the item is first, it takes 1 comparison (best case); if it is last or missing, it takes n comparisons (worst case). On average it takes about n Γ· 2 comparisons.
Binary search
A binary search only works on a sorted list. It compares the target with the middle item: if the target is smaller, it searches the left half; if larger, the right half. Each step throws away half of the list, so it is much faster than a linear search on a long list.
| Linear search | Binary search | |
|---|---|---|
| List must be sorted? | No | Yes |
| Comparisons (worst case, n items) | n | log2 n, rounded up |
| Best for | Short lists, or lists that change often | Long lists that stay sorted, such as a dictionary |
Worked example: binary search
Sorted list: 3, 7, 12, 19, 24, 31, 38. Find 31.
- Middle of 7 items is position 4:
19. 31 > 19, so search the right half:24, 31, 38. - Middle of the right half is
31. Found β in only 2 comparisons. A linear search would have needed 6.
With 1,000 sorted items, a binary search needs at most 10 comparisons (210 = 1,024), while a linear search could need 1,000.
- Using a binary search on an unsorted list β it will give the wrong answer.
- Forgetting that the list must be sorted first; sorting takes time too.
- Mixing up best and worst case: the best case for a linear search is 1 comparison, not 0.
1.3Sorting
Bubble sort
A bubble sort compares neighbouring pairs and swaps them if they are in the wrong order. After each pass, the largest unsorted item has "bubbled" to the end. Passes repeat until a pass makes no swaps.
Try it: bubble sort stepper
Type your own numbers, separated by commas, then press Step to watch each comparison.
Worked example: bubble sort
Sort 5, 1, 4, 2, 8 into ascending order.
- Pass 1: 5 > 1 swap β
1, 5, 4, 2, 8; 5 > 4 swap β1, 4, 5, 2, 8; 5 > 2 swap β1, 4, 2, 5, 8; 5 < 8 no swap. The 8 is now in its final place. - Pass 2: 1 < 4, 4 > 2 swap β
1, 2, 4, 5, 8; 4 < 5. The 5 is in place. - Pass 3: 1 < 2, 2 < 4 β no swaps. The list is sorted:
1, 2, 4, 5, 8.
Merge sort
A merge sort splits the list in half again and again until every piece has one item, then merges the pieces back together in order.
Sort 38, 27, 43, 3, 9, 82, 10:
- Split:
[38, 27, 43, 3]and[9, 82, 10]; keep splitting to single items. - Merge in order:
[27, 38]and[3, 43]merge to[3, 27, 38, 43];[9, 10, 82]on the other side. - Final merge:
[3, 9, 10, 27, 38, 43, 82].
| Bubble sort | Merge sort | |
|---|---|---|
| How it works | Swaps neighbouring pairs, pass by pass | Splits the list, then merges it back in order |
| Speed on a long list | Slow β many comparisons and swaps | Fast β far fewer comparisons on large lists |
| Extra memory | None β sorts in place | Needs extra space for the merged lists |
| Best for | Short lists, or lists that are nearly sorted | Long lists, where speed matters |
1.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Explain the difference between decomposition and abstraction. Give one example of each. [4]
- A sorted list has 200 items. What is the maximum number of comparisons a binary search needs? Show your working. [2]
- Use a bubble sort to sort
9, 4, 7, 2into ascending order. Show the list after each pass. [4] - A list of 500 student names is unsorted and changes every day. Explain whether a linear search or a binary search is better for finding a name in this list. [3]
- Decomposition is splitting a big problem into smaller sub-problems (e.g. a school app split into login, timetable and homework screens). Abstraction is ignoring details that do not matter and keeping only what is needed (e.g. a timetable needs the day and time, not the teacher's favourite colour).
- 27 = 128 and 28 = 256, so 200 items need at most 8 comparisons.
- Pass 1: 9 > 4 swap β
4, 9, 7, 2; 9 > 7 swap β4, 7, 9, 2; 9 > 2 swap β4, 7, 2, 9. Pass 2: 4 < 7; 7 > 2 swap β4, 2, 7, 9. Pass 3: 4 > 2 swap β2, 4, 7, 9. Pass 4: no swaps β sorted. - Linear search is better. The list is unsorted, so a binary search cannot be used at all, and sorting it every day would take longer than the search saves. A linear search works on the list as it is.
Topic 2 β Programming
This topic is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Programming
Writing and debugging programs in Python: sequence, selection and iteration, data types, arrays, operators and subprograms.
2.1Sequence, selection and iteration
Every program is built from three constructs:
- Sequence
- Instructions run one after another, in order. The program starts at the top and works down.
- Selection
- The program chooses a path with a condition β
if,elifandelsein Python. - Iteration
- The program repeats a block β a
forloop when you know how many times, awhileloop when you do not.
mark = int(input("Mark (0-100): "))
if mark >= 50:
print("Pass")
elif mark >= 40:
print("Borderline")
else:
print("Fail")
Indentation matters in Python. The lines inside an if or a loop must be indented by the same amount (usually 4 spaces). A line with the wrong indentation is a syntax error, and a line that is not indented at all runs outside the if or loop β a logic error that is easy to miss.
2.2Data types, variables and casting
| Data type | Meaning | Python example |
|---|---|---|
| Integer | A whole number | age = 17 |
| Real / float | A number with a decimal point | price = 12.5 |
| Boolean | True or False | passed = True |
| Character | One letter, digit or symbol | "A" |
| String | Text β a sequence of characters | name = "Aung" |
input() always returns a string, even when the user types a number. Cast it before doing arithmetic β otherwise "5" + "5" gives "55", not 10.
name = input("Name: ")
age = int(input("Age: "))
print("Hello", name)
print("Next year you will be", age + 1)
| Cast | Result |
|---|---|
| int("42") | 42 (whole number) |
| float("3.5") | 3.5 (decimal) |
| str(42) | "42" (text) |
Whole-number division and remainder: 17 // 5 is 3 and 17 % 5 is 2 (pseudocode DIV and MOD). Use round(x, 2) to round to 2 decimal places.
2.3Operators
| Operator | Meaning | Example |
|---|---|---|
| + - * / | Arithmetic | total = price * 3 |
| // % | Whole-number division, remainder | 7 // 2 = 3, 7 % 2 = 1 |
| == != < > <= >= | Comparison (gives True or False) | age >= 18 |
| and, or, not | Boolean (combine conditions) | age >= 13 and age <= 19 |
Precedence: brackets first, then * / // %, then + -, then comparisons, then not, and, or last. When in doubt, use brackets β they make the order clear to the reader as well as to the computer.
=assigns a value;==compares two values.if age = 18:is a syntax error.- Forgetting to cast
input()before arithmetic. - Comparing a string with a number, e.g.
if mark > "50":β a runtime error.
2.4Selection and iteration in Python
for i in range(1, 6): # count-controlled: runs 5 times
print(i)
count = 1
while count <= 5: # condition-controlled: runs while true
print(count)
count = count + 1
Use a for loop when you know how many times to repeat (a fixed number, or once per item in a list). Use a while loop when the repeat depends on a condition, such as "keep asking until the answer is correct". A while loop with a condition that never becomes false runs forever β always make sure the condition can change inside the loop.
Nested loops and selection
for row in range(1, 4):
for col in range(1, 4):
print(row * col, end=" ")
print()
The inner loop runs completely for every single run of the outer loop. Trace tables (Practical 3) are the best way to follow nested loops without getting lost.
2.5One- and two-dimensional arrays
An array stores several values of the same type under one name, each with an index. In Python, arrays are lists. The first item is at index 0.
scores = [72, 58, 91, 64] # one-dimensional array (a list)
print(scores[0]) # 72 β the first item
print(scores[2]) # 91 β the third item
scores[1] = 60 # change the second item
print(len(scores)) # 4 β the number of items
# two-dimensional array: a list of lists (rows and columns)
grid = [[1, 2, 3],
[4, 5, 6]]
print(grid[1][2]) # 6 β row 1, column 2
To work through an array, loop over its indexes or its items. To find the largest value, start with the first item as the largest so far, then compare each other item in turn.
2.6Subprograms with parameters
A subprogram is a named block of code that does one job. A function returns a value; a procedure does something but returns nothing. Parameters let the same subprogram work on different values.
def area(length, width): # length and width are parameters
return length * width
room = area(5, 4) # call with arguments 5 and 4
print(room) # 20
Variables made inside a subprogram are local β they exist only while the subprogram runs. Variables made outside are global. A subprogram should use its parameters and its return value, not reach out to global variables: that keeps it reusable and easier to test.
2.7Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Write a Python program that asks for a temperature in Celsius and prints "Hot" if it is above 30, "Warm" if it is 20 to 30, and "Cold" if it is below 20. [4]
- Explain the difference between a
forloop and awhileloop, giving one example of when each should be used. [4] - The list
marks = [45, 78, 62, 90, 55]holds five test marks. Write Python code to find and print the highest mark. [3] - Write a function
is_even(number)that returnsTrueif the number is even andFalseif it is odd. [3]
temp = float(input("Temperature: ")) if temp > 30: print("Hot") elif temp >= 20: print("Warm") else: print("Cold")- A
forloop repeats a fixed number of times or once per item (e.g. print the 12 times-table). Awhileloop repeats while a condition is true, when the number of repeats is not known in advance (e.g. keep asking for a password until it is correct). highest = marks[0] for mark in marks: if mark > highest: highest = mark print(highest)def is_even(number): return number % 2 == 0
Topic 3 β Data
This topic is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Data
Binary and hexadecimal, how text, images and sound are stored, storage units, compression and encryption.
3.1Binary and hexadecimal
A computer stores everything as binary β patterns of 0 and 1 β because its circuits have two states: off and on. Hexadecimal (base 16) is a shorthand for people: one hex digit stands for exactly four bits.
| System | Base | Digits used |
|---|---|---|
| Denary (decimal) | 10 | 0β9 |
| Binary | 2 | 0, 1 |
| Hexadecimal | 16 | 0β9, AβF (A = 10, F = 15) |
To convert binary to denary, add the place values where the bit is 1: 10011100 = 128 + 16 + 8 + 4 = 156. To convert to hex, split into groups of four bits: 1001 1100 β 9 and C β 9C.
Try it: converter
Type in any box (0 to 255). The other two update.
Binary addition and overflow
Work column by column from the right: 0 + 0 = 0; 0 + 1 = 1; 1 + 1 = 0 carry 1; 1 + 1 + 1 = 1 carry 1. Overflow happens when the answer needs more bits than the register holds β in 8 bits the largest value is 255, so 182 + 107 = 289 overflows and the stored answer is wrong.
Negative numbers: two's complement
In two's complement the left-most bit has the value β128 instead of +128, so the 8-bit range is β128 to +127. To find β45: write 45 as 00101101, invert every bit (11010010), then add 1 (11010011).
Logical shifts
A left shift by 1 multiplies by 2; a right shift by 1 divides by 2 (whole number). Bits that fall off the end are lost, so shifting can lose precision or cause overflow.
3.2How text, images and sound are stored
Text
Every character is given a number in a character set and stored in binary. ASCII uses 7 bits (128 characters: English letters, digits, punctuation). Unicode uses up to 32 bits and covers almost every language, including Myanmar script and emoji β but the same text takes more storage than ASCII.
Images
An image is a grid of pixels. Each pixel stores a colour as a binary number; the colour depth is the number of bits per pixel (24-bit colour = 8 bits each for red, green and blue). The resolution is the number of pixels (width Γ height). File size = width Γ height Γ colour depth (in bits) Γ· 8.
Worked example: a 1920 Γ 1080 photo at 24-bit colour = 1920 Γ 1080 Γ 24 bits = 49,766,400 bits = 6,220,800 bytes (about 6 MB) before compression.
Sound
Sound is stored as a series of samples. The sample rate is how many samples are taken per second (44,100 per second for CD quality). The bit depth is how many bits each sample uses (16 bits for CD). File size = sample rate Γ bit depth Γ duration (in seconds) Γ number of channels Γ· 8.
Worked example: 10 seconds of CD-quality stereo sound = 44,100 Γ 16 Γ 10 Γ 2 Γ· 8 = 1,764,000 bytes (about 1.7 MB).
3.3Storage units
| Unit | Size |
|---|---|
| Bit | One binary digit (0 or 1) |
| Nibble | 4 bits |
| Byte | 8 bits |
| Kilobyte (KB) | 1,024 bytes |
| Megabyte (MB) | 1,024 KB |
| Gigabyte (GB) | 1,024 MB |
| Terabyte (TB) | 1,024 GB |
3.4Compression
Compression makes files smaller so they use less storage and transfer faster.
| Lossless | Lossy | |
|---|---|---|
| Original data | Can be rebuilt exactly | Some data permanently removed |
| Size reduction | Smaller | Much smaller |
| Examples | PNG, FLAC, ZIP, run-length encoding (RLE) | JPEG, MP3, MP4 |
| Best for | Text, program files, medical images | Photos, music and video on the web |
Run-length encoding (RLE): store each value once with a count of how many times it repeats. AAAABBBCC becomes 4A3B2C. It works best on data with long runs, such as simple graphics. Lossy compression works by reducing resolution, colour depth or sample rate and dropping detail people barely notice.
3.5Encryption
Encryption scrambles readable plaintext into unreadable ciphertext using an algorithm and a key. It does not stop data being intercepted β it makes intercepted data useless without the key.
Caesar cipher
Each letter is shifted a fixed number of places along the alphabet. With a shift of 3, A β D, B β E, and Z wraps round to C. "HELLO" becomes "KHOOR". It is easy to break: there are only 25 possible shifts, so an attacker can try them all.
Vigenère cipher
Each letter is shifted by a different amount, taken from a keyword that repeats. With the keyword "KEY", the shifts are 10, 4, 24, 10, 4, 24 β¦ (K = 10, E = 4, Y = 24). The same letter encrypts to different letters in different positions, which makes it much harder to break than a Caesar cipher β but it is still breakable if the keyword is short or the message is long.
| Symmetric encryption | Asymmetric encryption | |
|---|---|---|
| Keys | One secret key encrypts and decrypts | A key pair: public key encrypts, private key decrypts |
| Main problem | The key must be shared, and could be stolen on the way | Slower, but the private key is never sent to anyone |
| Used for | Encrypting large amounts of data | Exchanging keys safely, for example in HTTPS |
- Saying encryption "stops hacking" β it does not stop data being stolen, it makes stolen data unreadable.
- Confusing compression with encryption: compression makes files smaller, encryption makes them secret.
- Forgetting the unit when you give a file size (bytes, KB or MB).
3.6Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Convert the denary number 200 into binary and hexadecimal. [3]
- An image is 800 Γ 600 pixels with a colour depth of 24 bits. Calculate its file size in bytes. [3]
- Explain one advantage and one disadvantage of lossy compression compared with lossless compression. [4]
- Encrypt the word "CAT" using a Caesar cipher with a shift of 5. Explain why a Caesar cipher is easy to break. [3]
- 200 = 128 + 64 + 8 β binary
11001000. Split into nibbles:1100 1000β C and 8 β hexadecimalC8. - 800 Γ 600 Γ 24 = 11,520,000 bits. 11,520,000 Γ· 8 = 1,440,000 bytes.
- Advantage: lossy files are much smaller, so they download faster and use less storage. Disadvantage: data is permanently lost, so the quality is lower and the original can never be recovered β unsuitable for text or medical images.
- C + 5 = H, A + 5 = F, T + 5 = Y β "HFY". It is easy to break because there are only 25 possible shifts, so an attacker can try every shift in seconds.
Topic 4 β Computers
This topic is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Computers
How a computer works: the inputβprocessβoutput model, the CPU and the fetchβdecodeβexecute cycle, logic gates, operating systems and programming languages.
4.1The inputβprocessβoutput model
Every computer system follows the same pattern: input β process β output, with storage holding data and programs.
- Input devices
- Keyboard, mouse, scanner, microphone, camera, sensors β they put data into the system.
- Processor (CPU)
- Carries out instructions and calculations on the data.
- Output devices
- Monitor, printer, speakers, actuators β they present results or cause an action.
- Storage
- Main memory (RAM and ROM) for data in use now; secondary storage (hard drive, SSD, USB stick) for data kept long term.
| RAM | ROM | |
|---|---|---|
| Volatile? | Yes β loses data when power is off | No β keeps data without power |
| Can it be changed? | Yes β read and write | Mostly read-only (holds the boot program) |
| Speed | Fast | Slower than RAM |
4.2The CPU and the fetchβdecodeβexecute cycle
The central processing unit (CPU) follows the Von Neumann architecture: program instructions and data are stored together in main memory and fetched one at a time.
- Arithmetic logic unit (ALU)
- Carries out calculations and logical comparisons.
- Control unit (CU)
- Fetches and decodes instructions and sends control signals to coordinate the rest of the computer.
- Program counter (PC)
- Holds the address of the next instruction.
- Memory address register (MAR)
- Holds the address of the memory location to be read from or written to.
- Memory data register (MDR)
- Holds the data or instruction just fetched from memory, or about to be written to it.
- Current instruction register (CIR)
- Holds the instruction being decoded and executed.
- Accumulator (ACC)
- Holds the results of ALU calculations.
The fetchβdecodeβexecute cycle repeats millions of times a second:
- Fetch: the PC gives the address of the next instruction; the instruction is copied from memory into the MDR, then into the CIR; the PC increases by one.
- Decode: the control unit works out what the instruction means.
- Execute: the instruction is carried out β by the ALU, or by reading or writing data.
What makes a CPU faster?
- Clock speed β more cycles per second (measured in GHz) means more instructions per second. A faster clock also uses more power and makes more heat.
- Number of cores β more cores can run more instructions at the same time. This helps most when the software can split its work across cores.
- Cache size β a larger cache keeps more instructions and data close to the CPU, so it waits less for main memory.
- More RAM helps when a program's data does not fit in memory, but it does not make the CPU itself faster.
4.3Logic gates and truth tables
A logic gate takes binary inputs (1 = true / on, 0 = false / off) and gives one output. NOT has one input; every other gate you need has two. Try each one:
Try it: gate playground
Switch A and B on and off. Each gate shows its output. NOT uses only A.
| Gate | Rule | Boolean form |
|---|---|---|
| NOT | Output is the opposite of the input | X = NOT A |
| AND | Output 1 only when both inputs are 1 | X = A AND B |
| OR | Output 1 when at least one input is 1 | X = A OR B |
| NAND | NOT AND: the opposite of AND | X = NOT (A AND B) |
| NOR | NOT OR: the opposite of OR | X = NOT (A OR B) |
| XOR | Output 1 when the inputs are different | X = A XOR B |
Truth tables
| A | B | AND | OR | NAND | NOR | XOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Circuits join gates so the output of one is the input of another. Work from the inputs towards the output, and add one column for every gate. With n inputs a truth table has 2n rows (two inputs: 4 rows; three inputs: 8 rows). List the input rows in binary counting order.
Try it: truth table builder
Choose an expression. The table shows the working column for each gate.
4.4Operating systems and utility software
The operating system (OS) is the software that manages the computer and lets the user and the programs use it. Its jobs include: managing memory, managing files, providing a user interface, managing hardware and peripherals (with drivers), security (user accounts and passwords), and multitasking (sharing the CPU between programs).
Utility software does maintenance jobs: anti-virus software finds and removes malware; backup software copies files so they can be restored; defragmentation reorganises files on a hard drive so they load faster; compression software makes files smaller.
4.5High-level and low-level languages
| Low-level | High-level | |
|---|---|---|
| Examples | Machine code (binary), assembly language | Python, Java, C# |
| Who it is for | The processor | People β closer to English |
| Speed | Runs fastest, no translation needed | Needs translating, so usually slower |
| Portability | Written for one processor only | Can run on many machines |
High-level code must be translated before the computer can run it. A compiler translates the whole program at once into machine code, which is then saved and run; an interpreter translates and runs it one line at a time, which is slower but easier for finding errors while you develop. Assembly language is translated by an assembler.
- Saying ROM is "the same as" secondary storage β ROM is main memory that holds the boot program; a hard drive is secondary storage.
- Mixing up the MAR and the MDR: the MAR holds the address, the MDR holds the data.
- Forgetting that a compiler translates the whole program before it runs, while an interpreter translates line by line as it runs.
4.6Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Describe the three stages of the fetchβdecodeβexecute cycle. [3]
- A computer has a 2 GHz processor and a 4 GHz processor is fitted. Explain two other ways the computer's performance could be improved. [4]
- Draw the truth table for
X = (A AND B) OR NOT C. [4] - State two jobs of an operating system and two examples of utility software. [4]
- Fetch: the instruction is copied from memory (address in the PC) into the MDR and then the CIR, and the PC increases by one. Decode: the control unit works out what the instruction means. Execute: the instruction is carried out by the ALU or by reading/writing data.
- Any two of: add more cores so more instructions run at the same time; increase the cache size so the CPU waits less for memory; add more RAM so programs do not need to use slow secondary storage while running. (Increasing clock speed further would also help but was already done in the question.)
- Three inputs β 8 rows. Work out the
A AND Bcolumn, then theNOT Ccolumn, then OR them: X = 1 except when A AND B = 0 and C = 1. Rows (A B C β X): 000β1, 001β0, 010β1, 011β0, 100β1, 101β0, 110β1, 111β1. - Operating system: any two of managing memory, managing files, providing a user interface, managing hardware/peripherals, security, multitasking. Utility software: any two of anti-virus, backup, defragmentation, compression.
Topic 5 β Communication and the Internet
This topic is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Communication and the Internet
How computers talk to each other: networks, the hardware that connects them, the protocols that agree the rules, and how to keep a network safe.
5.1Networks
A network is two or more computers connected so they can share data and resources, such as printers and files.
| LAN (Local Area Network) | WAN (Wide Area Network) | |
|---|---|---|
| Size | One building or site (a school, an office) | Across cities or countries β the internet is the largest WAN |
| Speed | Fast | Slower (long distances, many routers) |
| Who owns it | One organisation | Many owners, linked together |
Network hardware: a network interface card (NIC) connects a device to the network and gives it a unique MAC address; a router connects networks together and sends packets towards their destination; a switch connects devices inside a LAN and sends data only to the device it is for; a modem converts digital signals to analogue for a phone line (and back); a wireless access point (WAP) lets Wi-Fi devices join the network.
Topologies
- Star
- Every device connects to a central switch. If one cable fails, only that device is affected; if the switch fails, the whole network stops. Most LANs use star.
- Bus
- All devices share one cable. Cheap, but a break in the cable stops the whole network, and only one device can send at a time.
- Mesh
- Devices connect to several others, so there is always another route if one fails. Very reliable, but expensive in cabling.
Clientβserver and peer-to-peer
In a clientβserver network, a server provides services (files, email, web pages) and clients request them β the server is powerful, centrally managed and backed up, but expensive. In a peer-to-peer network, devices share files directly with each other β cheap and simple, but harder to secure and back up, and a slow device slows everyone.
5.2Protocols
A protocol is a set of rules that devices agree to follow so they can communicate. Without agreed rules, one device's data would be meaningless to another.
| Protocol | What it does |
|---|---|
| TCP/IP | The rules of the internet: TCP splits data into packets, numbers them and checks they arrive; IP addresses the packets and routes them. |
| HTTP / HTTPS | Transfers web pages. HTTPS adds encryption (SSL/TLS), so passwords and card details cannot be read on the way. |
| FTP | Transfers files between computers. |
| SMTP | Sends email from a client to a mail server, and between mail servers. |
| DNS | Turns a domain name (www.wailinhtet.com) into an IP address the computer can use. |
An IP address identifies a device on a network (and can change). A MAC address is built into the network card and never changes. Data travels in packets, each with a header (sender and destination addresses, packet number) and a payload; routers read the header and choose the best route at that moment.
5.3Network security
Threats to a network:
- Malware β viruses, worms, spyware and ransomware that damage, steal or lock data.
- Phishing β fake emails or websites that trick people into giving away passwords.
- Hacking β unauthorised access, often through weak passwords or unpatched software.
- Denial of service (DoS) β flooding a server with requests so real users cannot get in.
Defences:
- Firewall β software or hardware that checks traffic in and out of the network and blocks anything that breaks its rules.
- Strong passwords and user access levels β each user can only reach what they need; accounts are locked after too many wrong tries.
- Encryption β data is scrambled so it is useless if intercepted (HTTPS, encrypted Wi-Fi).
- Anti-malware software and updates β scans files and patches the holes attackers use.
- Proxy server β sits between users and the internet, filtering requests and hiding the internal network.
5.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Explain the difference between a LAN and a WAN. Give one example of each. [4]
- Describe the jobs of a router and a switch in a network. [4]
- A school uses a star topology. Explain one advantage and one disadvantage of this choice. [4]
- A student receives an email asking them to "confirm" their password by clicking a link. Name this threat and describe two ways to protect against it. [3]
- A LAN covers a small area such as one building, is fast and owned by one organisation (e.g. a school network). A WAN covers a large area such as a country or the world, is slower and owned by many organisations (e.g. the internet).
- A router connects different networks together and forwards packets towards their destination using IP addresses. A switch connects devices inside one LAN and sends data only to the device it is addressed to.
- Advantage: if one cable fails, only that one device is affected β the rest of the network keeps working. Disadvantage: if the central switch fails, the whole network stops.
- Phishing. Protection: do not click links in unexpected emails β go to the real website yourself; check the sender's address carefully; never give a password by email; report the email to the teacher or IT staff.
Topic 6 β The Bigger Picture
This topic is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
The Bigger Picture
What computing means for people and the planet: ethical questions, the law, and the environment.
6.1Ethical issues
Technology brings benefits, but it also creates questions with no simple answer. In the exam, you are usually asked to discuss both sides of an issue, not to pick one.
- Privacy
- Companies and governments collect huge amounts of personal data. People gain convenience (personalised services, safety) but lose control over who knows what about them. CCTV, location tracking and social media posts can all be used in ways the person did not expect.
- Surveillance
- Cameras, phone tracking and workplace monitoring can make places safer and workplaces fairer β but they can also be used to watch people without good reason, and data collected for one purpose can be used for another.
- AI and bias
- AI systems learn from data. If the data is biased, the system makes unfair decisions β for example, a hiring system trained on past data may favour one group of applicants. Someone must be responsible when an AI system gets it wrong.
- Digital divide
- Not everyone has the same access to computers and the internet. People without access are left behind in education, work and services that move online.
- Social media and health
- Social media connects people and spreads information quickly, but it can also spread false information, encourage addiction and harm mental health, especially for young people.
6.2Legal issues
Laws set the rules for how computers and data may be used. The main laws you need to know:
| Law | What it covers |
|---|---|
| Data Protection Act 2018 (UK, with GDPR) | Personal data must be collected fairly and lawfully, kept secure, kept no longer than needed, and not shared without a lawful reason. People have the right to see their own data and ask for it to be corrected or deleted. |
| Computer Misuse Act 1990 | It is a crime to access a computer system without permission, to access it with intent to commit a further crime, or to change or delete data without permission. Hacking and writing malware are offences. |
| Copyright, Designs and Patents Act 1988 | Creative work (software, music, films, images, text) belongs to its creator. Copying, sharing or using it without permission β including pirated software and music β is illegal. |
Other legal points: software is usually licensed, not sold β the licence says how many computers may use it and what you may do with it. Open-source software can be used and changed freely under its licence, but the licence terms still apply.
6.3Environmental issues
- E-waste: old phones and computers contain toxic materials (lead, mercury) and valuable metals. Thrown away carelessly, they poison soil and water; recycled properly, the metals can be recovered.
- Energy use: data centres, networks and devices use large amounts of electricity. Streaming video and training large AI models use far more energy than most people realise.
- Manufacturing: making a device uses raw materials, water and energy, and creates waste β so a phone's environmental cost starts before it is ever switched on.
- Planned obsolescence: devices are designed to be replaced rather than repaired, which increases waste. Repairing, reusing and recycling reduce the impact.
6.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Discuss the ethical issues of a school using CCTV cameras in classrooms. Give one argument for and one against. [4]
- Explain how the Data Protection Act protects a person's data. Give two rules the Act sets. [4]
- A student downloads a pirated copy of a program instead of buying it. Which law is broken, and what is one consequence? [2]
- Describe two environmental problems caused by old computers and phones, and one way each problem can be reduced. [4]
- For: cameras can deter bullying and theft and give evidence if an incident happens. Against: students and teachers lose privacy, and the recordings could be watched or shared without good reason. On balance, cameras in corridors and entrances are more acceptable than in classrooms.
- Personal data must be collected fairly and lawfully and kept secure; it must not be kept longer than needed; people have the right to see their data and ask for it to be corrected or deleted.
- The Copyright, Designs and Patents Act 1988 is broken. Consequences include a fine, and the pirated copy may contain malware.
- Toxic materials (lead, mercury) can poison soil and water if dumped β reduce by recycling e-waste through proper schemes. Making new devices uses raw materials and energy β reduce by repairing and reusing devices instead of replacing them.
Paper 2 Β· Application of Computational Thinking
Practical Python exam practice: writing and debugging programs, modifying starter code, algorithms in code, pseudocode and trace tables.
Practical 1 β Writing and Debugging Python Programs
This section is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Writing and Debugging Python Programs
Paper 2 is a practical exam on a computer. These sections teach the exam skills: writing programs from a description, finding and fixing errors, testing, and working with files.
P1.1From a description to a program
Paper 2 tasks give you a description in words. Before you type any code, plan it in three lines:
- Input β what data comes in, and how (keyboard, a file, a list)?
- Process β what must happen to the data (calculations, decisions, repeats)?
- Output β what must be shown, and in what format?
Worked example: "A shop gives a 10% discount when the total is over 100,000 kyat. Write a program to ask for the total and print the amount to pay."
total = float(input("Total: "))
if total > 100000:
pay = total * 0.9
else:
pay = total
print("Amount to pay:", round(pay, 2))
P1.2Errors: finding and fixing them
| Error type | What happens | Example |
|---|---|---|
| Syntax error | The program will not run. Python shows an error message and the line number. | if age > 18 (missing colon) |
| Runtime error | The program starts, then crashes. The error message names the line and the problem. | print(10 / 0) (division by zero) |
| Logic error | The program runs, but the answer is wrong. No error message β you must find it yourself. | total = price - discount (should be +) |
How to debug: read the error message first β it names the line and the kind of error. For logic errors, add temporary print() statements to show the value of a variable at each step, or trace the program by hand. Test with simple numbers you can check in your head.
P1.3Testing
Choose test data that covers the three cases examiners look for:
- Normal data
- Ordinary values the program should accept, e.g. a mark of 75.
- Boundary data
- Values at the edge of what is allowed, e.g. a mark of 0 and a mark of 100 β where programs most often go wrong.
- Erroneous data
- Values the program should reject, e.g. a mark of β5 or 101 β the program should handle them, not crash.
Write a small test table: test data, expected result, actual result, pass or fail. If the actual result differs, that is where the bug is.
P1.4Reading and writing text files
Paper 2 tasks often give you a file to read and ask you to write results to a file. The pattern is always the same:
names = []
with open("names.txt") as f:
for line in f:
names.append(line.strip())
with open("results.txt", "w") as f:
for name in names:
f.write(name + "\n")
open("names.txt") reads; open("results.txt", "w") writes (and erases the old file, so be careful). line.strip() removes the newline at the end of each line. with closes the file for you when the block ends.
P1.5Practice questions
These are practice questions written for this course β they are not from a real past paper.
- A program asks for a mark (0β100) and prints "Pass" if it is 50 or more. Give one normal, one boundary and one erroneous test value, with the expected result for each. [3]
- The program below crashes. Name the error type and fix it:
age = int(input("Age: "))followed byprint("In 10 years: " + age + 10). [2] - Write a program that reads five numbers from the keyboard and prints their total and their average. [4]
- Normal: 75 β "Pass". Boundary: 50 β "Pass" (and 0 β "Fail"). Erroneous: β5 β the program should reject it or ask again, not print "Pass" or crash.
- Runtime error (TypeError): you cannot add a string and a number with
+. Fix:print("In 10 years:", age + 10)β a comma prints both parts. total = 0 for i in range(5): num = float(input("Number: ")) total = total + num print("Total:", total) print("Average:", total / 5)
Practical 2 β Algorithms in Code
This section is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Algorithms in Code
Turning the standard algorithms into Python: linear and binary search, bubble sort and merge sort β and modifying starter code, which is how Paper 2 usually asks for them.
P2.1Linear and binary search in Python
def linear_search(items, target):
for i in range(len(items)):
if items[i] == target:
return i
return -1
names = ["Aung", "Htar", "May", "Zaw"]
print(linear_search(names, "May")) # 2
print(linear_search(names, "Ko")) # -1 (not found)
def binary_search(items, target): # items MUST be sorted
low = 0
high = len(items) - 1
while low <= high:
mid = (low + high) // 2
if items[mid] == target:
return mid
elif items[mid] < target:
low = mid + 1
else:
high = mid - 1
return -1
The binary search needs low <= high, not low < high β with < alone, a list with one item left is never checked. Returning -1 for "not found" is the standard choice, because β1 can never be a real index.
P2.2Bubble sort and merge sort in Python
def bubble_sort(items):
n = len(items)
for i in range(n - 1):
swapped = False
for j in range(n - 1 - i):
if items[j] > items[j + 1]:
items[j], items[j + 1] = items[j + 1], items[j]
swapped = True
if not swapped:
break
return items
The swapped flag is the early stop: if a whole pass makes no swaps, the list is already sorted and the sort can finish. Without it, the sort still works β it just does wasted passes.
def merge_sort(items):
if len(items) <= 1:
return items
mid = len(items) // 2
left = merge_sort(items[:mid])
right = merge_sort(items[mid:])
result = []
i = j = 0
while i < len(left) and j < len(right):
if left[i] <= right[j]:
result.append(left[i]); i += 1
else:
result.append(right[j]); j += 1
result += left[i:] + right[j:]
return result
P2.3Modifying starter code
Paper 2 often gives you starter code and asks you to change it. Read the starter code first and work out what each part does before you change anything. Common changes: add a new condition, change a loop, add a count, or store results in a list.
Worked example β starter code prints the numbers 1 to 10. Task: change it so it prints only the even numbers, and counts how many there are.
# Starter code
for i in range(1, 11):
print(i)
# Modified code
count = 0
for i in range(1, 11):
if i % 2 == 0:
print(i)
count = count + 1
print("Even numbers:", count)
- Changing the starter code before reading it β you may break a part that already worked.
- Forgetting to reset a counter (like
count = 0) before the loop. - Using
range(1, 10)when you need 1 to 10 βrangestops one short.
P2.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Write a Python function
count_above(marks, limit)that returns how many marks in the list are above the limit. [4] - The list
scores = [88, 45, 92, 61, 73]is unsorted. A program needs to find the score 61. Explain which search you would use and why. Then state how many comparisons it makes in the worst case. [3] - Modify the bubble sort in Β§P2.2 so it sorts into descending order. State the one line you change. [2]
def count_above(marks, limit): count = 0 for mark in marks: if mark > limit: count = count + 1 return count- Use a linear search: the list is unsorted, so a binary search cannot be used. Worst case it makes 5 comparisons (the target is last, or not there at all).
- Change
if items[j] > items[j + 1]:toif items[j] < items[j + 1]:β swap when the left item is smaller, so the larger values bubble to the front.
Practical 3 β Pseudocode and Trace Tables
This section is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Pseudocode and Trace Tables
Paper 2 gives you a pseudocode reference sheet. This section teaches you to read it, write it, and follow it with a trace table β the skill that turns a confusing program into marks.
P3.1Reading pseudocode
Pseudocode is not a programming language β it is a way of writing an algorithm so a person can read it. The exam gives you a reference sheet with the exact words it uses. The ones you will meet most often:
| Pseudocode | Meaning | Python |
|---|---|---|
| DECLARE X : INTEGER | Create a variable called X | x = 0 |
| X β 5 | Give X the value 5 | x = 5 |
| INPUT X | Read a value into X | x = input() |
| OUTPUT X | Show the value of X | print(x) |
| IF β¦ THEN β¦ ELSE β¦ ENDIF | Choose a path | if β¦ else: |
| FOR i β 1 TO 5 | Repeat 5 times | for i in range(1, 6): |
| WHILE β¦ DO β¦ ENDWHILE | Repeat while true | while β¦: |
| REPEAT β¦ UNTIL β¦ | Repeat at least once, until true | while True: β¦ if β¦: break |
| LENGTH(Text) | Number of characters | len(text) |
| SUBSTRING(Text, 1, 3) | Characters 1 to 3 | text[0:3] |
Read pseudocode the same way you read Python: line by line, top to bottom, following the branches and loops. The only real differences are the words (β instead of =, ENDIF instead of indentation) and the fact that array indexes start at 1 in pseudocode but at 0 in Python.
P3.2Trace tables
A trace table follows a program one line at a time and writes down the value of every variable after each step. It is the best way to find the output of a program β and to find a logic error.
Worked example:
Total β 0
FOR Count β 1 TO 3
INPUT Number
Total β Total + Number
NEXT Count
OUTPUT Total
Inputs: 4, 7, 2.
| Total | Count | Number | Output |
|---|---|---|---|
| 0 | β | β | β |
| 0 | 1 | 4 | β |
| 4 | 1 | 4 | β |
| 4 | 2 | 7 | β |
| 11 | 2 | 7 | β |
| 11 | 3 | 2 | β |
| 13 | 3 | 2 | β |
| 13 | 3 | 2 | 13 |
Rules for a good trace table: one column per variable (and one for the output); one row per step, not per line of code; write the value only when it changes; never skip the first row, which shows the starting values.
P3.3Validation and verification
Before data is processed, check it. Validation is done by the program: a range check (is a mark between 0 and 100?), a presence check (is the field empty?), a type check (is it a number?), a length check (is the password at least 8 characters?). If the data fails, the program asks again instead of crashing or storing bad data.
Verification is done by the person: checking the data was entered correctly β typing it twice and comparing, or reading it back on screen and confirming. Validation checks the data is reasonable; verification checks it is correct.
P3.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Complete the trace table for this pseudocode with the inputs 3 and 5, and state the output. [4]
Count β 0INPUT AINPUT BWHILE A < B DOA β A + 1Count β Count + 1ENDWHILEOUTPUT Count - A program asks for a student's age. Give one validation check that should be used, and explain what the program should do if the check fails. [3]
- Explain the difference between validation and verification. [2]
- Start: Count = 0. INPUT A = 3, INPUT B = 5. Loop: 3 < 5 β A = 4, Count = 1. Loop: 4 < 5 β A = 5, Count = 2. Loop: 5 < 5 is false, so the loop stops. Output: 2.
- Range check: age must be between 0 and 120 (or a sensible school range such as 5 to 25). If it fails, the program should show an error message and ask for the age again, not store the bad value.
- Validation is the program checking that data is reasonable (range, type, presence) before it is used. Verification is the person checking that data is correct (typing it twice, or checking it on screen).
Practical 4 β Paper 2 Exam Practice
This section is for approved SrWL Learning students. Sign in with Google to unlock it β Topic 1 is free to read now.
Paper 2 Exam Practice
How the 3-hour practical exam works, how to plan your time, and one full worked exam-style task from start to finish.
P4.1How the Paper 2 exam works
Paper 2 is a 3-hour practical exam on a computer (80 marks, 50% of the qualification). It is a supervised session: you work on the machine, using Python (the other approved languages are C# and Java, but this course teaches Python). The exam has two parts: written questions (short answers about code, algorithms and data) and practical tasks (writing and changing programs on the computer). A pseudocode reference sheet is given to you in the exam, so you do not need to memorise the pseudocode words.
You may be given starter code or data files to work with. Your work is saved and marked afterwards β so save often, and make sure your final program is the one you want marked.
P4.2A time plan for 3 hours
| Time | What to do |
|---|---|
| 0:00 β 0:15 | Read the whole paper. Note the written questions and the practical tasks, and how many marks each is worth. |
| 0:15 β 0:45 | Answer the written questions first β they are quick marks and they warm you up for the coding. |
| 0:45 β 2:30 | Work through the practical tasks in order. Read each task fully, plan (inputβprocessβoutput), then code and test. |
| 2:30 β 2:50 | Test everything with the test data in the question. Fix anything that crashes or gives a wrong answer. |
| 2:50 β 3:00 | Save all files. Check that the files are in the right place and that your name is on your work if asked. |
If you are stuck on one task for more than 15 minutes, move on and come back to it. Marks are spread across the paper β a half-finished easy task is worth more than a perfect hard one you never reach.
P4.3Full worked exam-style task
Task: A club keeps its members' names and ages in a file called members.txt (one member per line, name then age, separated by a comma). Write a program that:
- Reads all the members from the file.
- Counts how many members are under 18.
- Writes the names of the under-18 members to a file called
juniors.txt. - Prints the number of junior members.
juniors = []
count = 0
with open("members.txt") as f:
for line in f:
parts = line.strip().split(",")
name = parts[0]
age = int(parts[1])
if age < 18:
juniors.append(name)
count = count + 1
with open("juniors.txt", "w") as f:
for name in juniors:
f.write(name + "\n")
print("Junior members:", count)
What the examiner is looking for: reading the file line by line, splitting each line on the comma, casting the age to an integer, the condition age < 18, writing the names to the output file, and printing the count. A program that does all of these, even with a small slip in one line, earns most of the marks.
- Forgetting to strip the newline, so the age has a hidden character and the cast fails.
- Forgetting to cast the age to an integer, so
age < 18compares text with a number and crashes. - Writing the output file but never closing it or never saving the program β the marker only sees what is saved.
- Spending the whole exam on one hard task and leaving easy marks unanswered.
P4.4Practice questions
These are practice questions written for this course β they are not from a real past paper.
- Paper 2 is 3 hours long and worth 80 marks. How many minutes should you spend, on average, on each mark? [1]
- A practical task asks you to read numbers from a file, find the largest, and print it. List the four steps you would take before writing any code. [2]
- Explain why Paper 2 gives you a pseudocode reference sheet, and how you should use it during the exam. [2]
- 180 minutes Γ· 80 marks = about 2 minutes per mark β so a 10-mark task should take about 20 minutes.
- Read the task fully; plan inputβprocessβoutput; write the code in small pieces; test with the test data in the question.
- So you do not have to memorise the pseudocode words and can spend your time on solving the problem. Use it to check the exact wording (for example
LENGTH,SUBSTRING,β) when you read or write pseudocode.