Lesson 1 · Data

🔤 Data Representation

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

13 in binary128643216842100001101
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.

8 × 8 image, 1 bit per pixel (black/white): 64 · 1 = 64 bits = 8 bytes 10 × 10 image, 8 bits per pixel: 100 · 8 = 800 bits = 100 bytes sound: size = sample rate · bits · seconds
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

Common data typesTypeExampleStoresinteger42whole numbersfloat3.14decimal numbersstring"hello"textbooleanTruetrue or false
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, < > <= >=.

if score >= 50: print "Pass" else: print "Fail" score = 50 → Pass score = 49 → Fail

🖼️ See it

Selection: if … elseTest the conditionscore >= 50 ?If trueprint "Pass"Otherwiseprint "Try again"
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

A while loopCheck theconditionRun the loop bodyUpdate thecounterrepeat whiletrue
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.

nums = [4, 9, 2, 7] nums[0] = 4 nums[2] = 2 len(nums) = 4 last index = 3 nums[1] = nums[1] + 1 → [4, 10, 2, 7] sum = 4 + 9 + 2 + 7 = 22

🖼️ See it

Binary search on a sorted listLook at themiddle itemIs it the target?if yes, stopDiscard the wronghalfRepeat on what isleft
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

A home networkLaptopWi-FiPhoneWi-FiPrintercable or Wi-FiThe Internetvia your ISPRouter
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.

500 MB file at 25 MB/s → 20 s 200 Mbps = 200 / 8 = 25 MB/s packets: 1 MB message, 1000 bytes per packet 1 000 000 / 1000 = 1000 packets
Latency is the delay before data starts to arrive, which matters for video calls and games.
✏️ Quick check · 1 of 7
DNS

DNS is used to:

Names to numbers.
✏️ Quick check · 2 of 7
Router

A router:

Directions.
✏️ Quick check · 3 of 7
Packet

Why is data split into packets?

Small pieces.
✍️ Type your answer · 4 of 7

A 500 MB file downloads at 25 MB/s.

How many seconds does it take?

Enter an exact answer, without rounding.
s
time = size / speed.
✍️ Type your answer · 5 of 7

A connection is 200 Mbps (megabits per second).

What is that in MB/s?

Enter an exact answer, without rounding.
MB/s
Divide by 8.
✍️ Type your answer · 6 of 7

A message of 1 000 000 bytes is sent in packets of 1000 bytes.

How many packets are needed?

Enter an exact answer, without rounding.
Divide.
✍️ Type your answer · 7 of 7

A network has 24 usable device addresses and 9 are already used.

How many are left?

Enter an exact answer, without rounding.
Subtract.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5

A LAN covers:

Question 2 of 5

An IP address:

Question 3 of 5

Higher bandwidth means:

Question 4 of 5

A web server:

Question 5 of 5

Wi-Fi sends data using:

Final Challenge

🏆 12-Question Challenge Quiz

Questions from every topic in this course. Pick an answer for each one, then hit Check My Answers.

0 / 12
💪 Keep practicing — go back through the lessons and retake the quiz!
Q1 · Data Representation

The hexadecimal number A represents:

Q2 · Data Representation

Increasing the sample rate of a sound recording:

Q3 · Variables, Types & Operators

What does 20 MOD 6 equal?

Q4 · Variables, Types & Operators

A constant is a value that:

Q5 · Selection & Conditions

The value of True AND False is:

Q6 · Selection & Conditions

Which test finds a number that is NOT equal to 5?

Q7 · Loops & Iteration

What is the sum of 1 + 2 + 3 + 4?

Q8 · Loops & Iteration

What does total = total + i do in a loop?

Q9 · Lists & Searching

Which index is the third item?

Q10 · Lists & Searching

In a linear search the worst case is when the item is:

Q11 · Networks & the Web

The process of sending data in small pieces is called:

Q12 · Networks & the Web

Wi-Fi sends data using: