Text, pictures and sound are all stored as numbers, and those numbers are stored in binary. Learning the code explains file sizes.
🔠 Hexadecimal and text
Hexadecimal (base 16) uses 0–9 and A–F (A = 10 … F = 15). One hex digit stands for 4 bits, so it is a short way to write binary. Text is stored using a code such as ASCII, where each character has a number (A = 65, a = 97).
hex 1F = 1·16 + 15 = 31
hex FF = 15·16 + 15 = 255
binary 1010 1111 = hex AF
ASCII: A = 65, so C = 67
lowercase = uppercase + 32 → a = 97
🖼️ See it
Each bit is worth double the one to its right. 8 + 4 + 1 = 13, so 13 is 00001101 in binary.
🖼️ Images and sound
An image is a grid of pixels. File size in bits = width × height × bits per pixel. Sound is sampled many times a second.
More bits per pixel means more colours but a bigger file.
✏️ Quick check · 1 of 7
Hex digit
In hexadecimal, the letter F represents:
Count from A = 10.
✏️ Quick check · 2 of 7
Pixel
A pixel is:
Picture element.
✍️ Type your answer · 3 of 7
Convert the hexadecimal number 1F to decimal.
What is its value?
Enter an exact answer, without rounding.
F is 15.
✍️ Type your answer · 4 of 7
Convert the hexadecimal number FF to decimal.
What is its value?
Enter an exact answer, without rounding.
Both digits are 15.
✍️ Type your answer · 5 of 7
In ASCII the letter A is 65.
What is the code for C?
Enter an exact answer, without rounding.
Count on.
✍️ Type your answer · 6 of 7
A black-and-white image is 8 pixels wide and 8 high, with 1 bit per pixel.
How many bytes is the image?
Enter an exact answer, without rounding.
width × height × bits, then ÷ 8.
✍️ Type your answer · 7 of 7
An image is 10 × 10 pixels with 8 bits per pixel.
How many bytes is it?
Enter an exact answer, without rounding.
Divide by 8.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5
One hexadecimal digit represents how many bits?
Question 2 of 5
Why is hexadecimal used by programmers?
Question 3 of 5
Which would make an image file larger?
Question 4 of 5
ASCII is a code that:
Question 5 of 5
Increasing the sample rate of a sound recording:
Lesson 2 · Coding
🧮 Variables, Types & Operators
Programs store different kinds of data and combine them with operators. Choosing the right type matters.
🏷️ Data types
Common types: integer (whole numbers), float (decimals), string (text) and boolean (True/False). Adding two strings joins them (concatenation), but adding numbers adds them.
"3" + "4" = "34" (strings joined)
3 + 4 = 7 (integers added)
int("12") + 1 = 13 (casting a string to an integer)
🖼️ See it
The type decides which operations make sense: you can add two integers, or join two strings.
➗ Integer division and mod
DIV gives how many whole times one number fits in another, and MOD gives what is left over. Together they split a number into parts.
17 DIV 5 = 3 17 MOD 5 = 2
125 minutes = 125 DIV 60 = 2 hours, 125 MOD 60 = 5 minutes
even numbers: n MOD 2 = 0
Order of operations in code is the same as in maths: brackets, then * and /, then + and −.
✏️ Quick check · 1 of 7
Boolean
Which data type holds only True or False?
True or false.
✏️ Quick check · 2 of 7
Concatenation
What does "3" + "4" give when both are strings?
Joining text.
✍️ Type your answer · 3 of 7
Evaluate 17 DIV 5.
What is the answer?
Enter an exact answer, without rounding.
Whole number only.
✍️ Type your answer · 4 of 7
Evaluate 17 MOD 5.
What is the remainder?
Enter an exact answer, without rounding.
What is left over?
✍️ Type your answer · 5 of 7
Convert 125 minutes into hours and minutes. Use 125 DIV 60.
How many whole hours is that?
Enter an exact answer, without rounding.
Whole number only.
✍️ Type your answer · 6 of 7
Convert 125 minutes into hours and minutes. Use 125 MOD 60.
How many minutes are left over?
Enter an exact answer, without rounding.
The remainder.
✍️ Type your answer · 7 of 7
Evaluate 2 + 3 * 4.
What is the value?
Enter an exact answer, without rounding.
Order of operations.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5
Which is an integer?
Question 2 of 5
n MOD 2 = 0 tests whether n is:
Question 3 of 5
Casting means:
Question 4 of 5
Which type is best for storing a price like 4.99?
Question 5 of 5
A constant is a value that:
Lesson 3 · Coding
🔀 Selection & Conditions
Programs make decisions. Conditions are tests that are either true or false, and combining them lets a program react to many situations.
❓ If and else
An IF statement runs code only when a condition is true. ELSE covers the other case. Comparison operators: == equal, != not equal, < > <= >=.
Only one branch runs each time. Conditions are built from comparisons and combined with and, or and not.
🔗 AND, OR, NOT
AND is true only if both parts are true. OR is true if at least one part is true. NOT flips true and false.
age = 15, has_ticket = True
age >= 12 AND has_ticket → True
age >= 18 OR has_ticket → True
NOT has_ticket → False
grade: 90+ → A, 80+ → B, else C
score 85 → B
Test the boundaries: what happens at exactly 50, and at 49 and 51?
✏️ Quick check · 1 of 7
AND
A AND B is true when:
Both.
✏️ Quick check · 2 of 7
OR
A OR B is false when:
Neither is true.
✏️ Quick check · 3 of 7
Equality
Which operator tests if two values are equal?
Double.
✍️ Type your answer · 4 of 7
A grade program: if score >= 90 then 4; else if score >= 80 then 3; else 2.
What is the output for score 85?
Enter an exact answer, without rounding.
Check conditions in order.
✍️ Type your answer · 5 of 7
Using the same program, score = 90.
What is the output?
Enter an exact answer, without rounding.
The boundary counts.
✍️ Type your answer · 6 of 7
Program: x = 7. If x MOD 2 == 0 then y = 1 else y = 0.
What is y?
Enter an exact answer, without rounding.
Is 7 even?
✍️ Type your answer · 7 of 7
Program: a = 5, b = 8. If a > b then m = a else m = b.
What is m?
Enter an exact answer, without rounding.
It finds the larger one.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5
NOT True equals:
Question 2 of 5
Which condition is true when x is between 1 and 10?
Question 3 of 5
What does ELSE run?
Question 4 of 5
A nested IF is:
Question 5 of 5
Which test finds a number that is NOT equal to 5?
Lesson 4 · Coding
🔁 Loops & Iteration
Loops let a program repeat steps thousands of times without extra code. Counting loops and condition-controlled loops cover most tasks.
🔢 FOR and WHILE
A FOR loop repeats a set number of times. A WHILE loop repeats as long as a condition is true, so it may run zero times or forever if the condition never becomes false.
total = 0
for i in 1 to 5:
total = total + i # 1+2+3+4+5 = 15
n = 1
while n < 20:
n = n * 2 # 2, 4, 8, 16, 32
# stops when n = 32
🖼️ See it
When the condition becomes false the loop stops. If the counter is never updated the loop never ends.
🧾 Tracing with a table
A trace table records the value of each variable at every step, which makes loops easy to follow.
i total
1 1
2 3
3 6
4 10
5 15
multiplication table: for i in 1 to 10: print 7 * i
the 6th line is 42
Watch for infinite loops: something inside a WHILE loop must change the condition.
✏️ Quick check · 1 of 7
While loop
A WHILE loop repeats:
Condition.
✏️ Quick check · 2 of 7
Infinite loop
An infinite loop happens when:
It never ends.
✍️ Type your answer · 3 of 7
total = 0. for i in 1 to 5: total = total + i.
What is total at the end?
Enter an exact answer, without rounding.
Sum 1 to 5.
✍️ Type your answer · 4 of 7
n = 1. while n < 20: n = n * 2.
What is n when the loop ends?
Enter an exact answer, without rounding.
Trace each pass.
✍️ Type your answer · 5 of 7
for i in 1 to 10: print 7 * i.
What is the 6th number printed?
Enter an exact answer, without rounding.
i = 6.
✍️ Type your answer · 6 of 7
count = 0. for i in 1 to 20: if i MOD 3 == 0 then count = count + 1.
What is count at the end?
Enter an exact answer, without rounding.
Count the multiples of 3.
✍️ Type your answer · 7 of 7
x = 100. while x > 10: x = x / 2.
How many times does the loop run?
Enter an exact answer, without rounding.
Trace until x ≤ 10.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5
Which loop is best when you know how many repeats you need?
Question 2 of 5
A trace table is used to:
Question 3 of 5
How many times does for i in 0 to 4 run?
Question 4 of 5
Which statement is true about WHILE?
Question 5 of 5
What does total = total + i do in a loop?
Lesson 5 · Algorithms
📚 Lists & Searching
A list stores many values under one name. Searching a list is one of the most common jobs a program does.
🗃️ Lists
A list (array) holds items in order, each at an index starting at 0. You can read, change, add and remove items.
Each step halves the list, so 1000 items need only about 10 checks. The list must already be sorted.
🔍 Linear and binary search
Linear search checks each item in turn. Binary search works on a sorted list, looking in the middle and discarding half each time, so it is far faster for big lists.
linear search for 7 in [4, 9, 2, 7] → 4 comparisons
binary search in [2, 4, 7, 9, 12, 15, 20]:
middle = 9; look for 15 → right half
middle = 15 → found in 2 steps
list of 1000 sorted items: at most 10 steps (2¹⁰ = 1024)
Binary search only works if the list is sorted.
✏️ Quick check · 1 of 7
Index
In most languages the first item of a list has index:
Zero-based.
✏️ Quick check · 2 of 7
Binary search needs
Binary search needs the list to be:
Order.
✍️ Type your answer · 3 of 7
nums = [4, 9, 2, 7].
What is nums[2]?
Enter an exact answer, without rounding.
Start from 0.
✍️ Type your answer · 4 of 7
nums = [4, 9, 2, 7].
What does len(nums) return?
Enter an exact answer, without rounding.
Count them.
✍️ Type your answer · 5 of 7
nums = [4, 9, 2, 7].
What is the sum of the list?
Enter an exact answer, without rounding.
Add them.
✍️ Type your answer · 6 of 7
A linear search looks for 7 in [4, 9, 2, 7], starting at the left.
How many items are checked?
Enter an exact answer, without rounding.
Count until found.
✍️ Type your answer · 7 of 7
A sorted list has 1000 items. Binary search halves it each time (2¹⁰ = 1024).
What is the maximum number of steps needed?
Enter an exact answer, without rounding.
How many halvings?
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5
Which search is faster on a large sorted list?
Question 2 of 5
To append means to:
Question 3 of 5
Which expression gives the last item of a list called a with 5 items?
Question 4 of 5
A 2D list is:
Question 5 of 5
In a linear search the worst case is when the item is:
Lesson 6 · Networks
📡 Networks & the Web
Devices share information through networks. Understanding packets, addresses and speed explains why the internet works and sometimes slows down.
🌍 How data travels
Data is split into packets that may take different routes and are reassembled at the destination. Each device has an IP address, and DNS converts a domain name (example.com) into an IP address. A router directs packets.
LAN: local area network (a school, a home)
WAN: wide area network (the internet)
client requests → server responds
browser → DNS lookup → server → web page
🖼️ See it
The router passes data between your devices and the wider Internet, using IP addresses to deliver packets.
⏱️ Bandwidth
Bandwidth is how much data can be sent per second. Download time = file size ÷ speed. Remember 8 bits = 1 byte.