← IGCSE Computer Science Paper 1

Calculating a checksum

Add all the byte values in the block, then keep the remainder after dividing by 256 so the result fits in one byte. Example: 200+100+50=350, 350 mod 256 = 94.

Understanding Calculating a checksum in IGCSE Computer Science Paper 1

What it does: Adding the four byte values gives a total of 100, which is the first step before any reducing. MOD 256 discards the part of the total that does not fit in 8 bits, leaving a one-byte checksum. One byte holds 256 different values (0 to 255), so we take the remainder after dividing by 256. 200 + 100 + 50 = 350. 350 is too big for one byte, so 350 - 256 = 94. 10 + 20 + 30 + 40 = 100. This is already below 256, so it stays as 100. 255 + 1 = 256, and 256 mod 256 = 0. 256 cannot be stored in one byte.

Common mistakes: len(data) only counts how many bytes there are (3). A checksum needs the sum of the byte values, so it should be total = sum(data). A checksum is found by adding the bytes, not multiplying them. It should be total = a + b.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 168–178) and word search (Modules 168–188).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
How is a simple checksum calculated for a block of data?
Multiply all the byte values together and keep the first digitAdd up all the byte values and keep the result within one byte
Matches
checksum = (200 + 100 + 50) % 255
↓
The total is divided by 255 instead of 256. One byte holds 256 different values, so the modulus must be 256 (the correct answer is 94).
Applying
Meanings
Term
checksum = sum(bytes) % 256
Meaning
Add all the byte values in the block, then keep the remainder after dividing by 256 so the result fits in one byte. Example: 200+100+50=350, 350 mod 256 = 94.
Practice
data = [200, 100, 50]
Testing
Gaps
checksum = (bytes) % 256
Check Answer
Spots
1data = [200, 100, 50]
2total = len(data)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Barreleye Fish' badge — Clear Vision, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. How is a simple checksum calculated for a block of data?
A. Add up all the byte values and keep the result within one byte ✓
B. Multiply all the byte values together and keep the first digit
A simple checksum is the total of all the bytes in the block, reduced so that it fits in a single byte.
2. Which calculation keeps a total inside one byte?
A. total % 256 ✓
B. total % 100
One byte holds 256 different values (0 to 255), so we take the remainder after dividing by 256.
3. A block contains the bytes 200, 100 and 50. What is the checksum?
A. 350
B. 94 ✓
200 + 100 + 50 = 350. 350 is too big for one byte, so 350 - 256 = 94.
4. A block contains the bytes 10, 20, 30 and 40. What is the checksum?
A. 100 ✓
B. 244
10 + 20 + 30 + 40 = 100. This is already below 256, so it stays as 100.
5. The bytes 255 and 1 are added. What checksum do we get?
A. 256
B. 0 ✓
255 + 1 = 256, and 256 mod 256 = 0. 256 cannot be stored in one byte.

Match the Pairs

checksum = sum(bytes) % 256 → Add up every byte in the block, then keep the remainder after dividing by 256 so the checksum fits in one byte.
350 % 256 → Gives 94, because 350 is too big for one byte and 350 - 256 leaves 94.
The first step of a checksum is to add the values of all the bytes in the block together. → total = 12 + 30 + 8 + 50
If the total is more than 255, only the low byte is kept by taking the remainder after dividing by 256. → checksum = total MOD 256
checksum = (200 + 100 + 50) % 255 → The total is divided by 255 instead of 256. One byte holds 256 different values, so the modulus must be 256 (the correct answer is 94).
checksum = 200 + 100 + 50 → The bytes are added but the total is never reduced. 350 is greater than 255, so it does not fit in one byte; it needs % 256 to give 94.

Key Term

checksum = sum(bytes) % 256
Add all the byte values in the block, then keep the remainder after dividing by 256 so the result fits in one byte. Example: 200+100+50=350, 350 mod 256 = 94.

Fill in the Blanks

1. checksum = sum(bytes) % 256
Hint: Type the function that adds up all the byte values in the block.
2. checksum = sum(bytes) % 256
Hint: Type the operator that gives the remainder after dividing.
3. checksum = sum(bytes) % 256
Hint: Type the number of different values one byte can hold, which the total is divided by.
4. bytes = [200, 100, 50] total = sum(bytes) checksum = total % 256
Hint: Type the variable that holds the sum of all the bytes.
5. # 200 + 100 + 50 = 350 checksum = 350 % 256 print(checksum) # 94
Hint: Type the remainder when 350 is divided by 256, which is the final checksum.

Spot the Error

Question 1
A data = [200, 100, 50]
B total = len(data)
C checksum = total % 256
D print(checksum)
Line B — len(data) only counts how many bytes there are (3). A checksum needs the sum of the byte values, so it should be total = sum(data).
Question 2
A a = 200
B b = 100
C total = a * b
D checksum = total % 256
Line C — A checksum is found by adding the bytes, not multiplying them. It should be total = a + b.
Question 3
A total = 0
B for b in [200, 100, 50]
C total += b
D print(total % 256)
Line B — A for loop header must end with a colon. It should be for b in [200, 100, 50]:
Question 4
A data = [120, 80, 100
B total = sum(data)
C print(total % 256)
Line A — The list is missing its closing square bracket. It should be data = [120, 80, 100].
Question 5
A data = [255, 1, 2]
B total = sum(data)
C checksum = total // 256
D print(checksum)
Line C — // gives the whole-number quotient, not the remainder. The checksum is the remainder after dividing by 256, so use %.

Student with a class code? Join your class →