The Full Computing Booklet
Everything from Years 7, 8 and 9 woven into one flowing guide — with activities, quizzes, key terms, Python from zero to advanced, and loads of ways to check your understanding.
💭 What Do You Already Know?
Before reading, think about these questions. You don't need to write anything — just think!
- What do you do to stay safe when using the internet?
- What is a strong password? Can you give an example?
- Have you ever seen anything online that made you uncomfortable?
- What is the difference between the Internet and the World Wide Web?
🎯 Learning Objectives
- Understand your digital footprint and why it matters
- Know how to protect your online identity and privacy
- Recognise and respond to cyberbullying and inappropriate content
- Understand the difference between the Internet and the WWW
🦶 Your Digital Footprint
Every time you go online, you leave behind a trail of data called your digital footprint. This includes every post, search, photo, message and website visit.
📘 Key Term: Digital Footprint
The trail of data left behind whenever you use the internet. It can be active (things you choose to post) or passive (data collected without your knowledge).
💜 Did You Know?
Universities and employers regularly search for candidates online before interviews. A negative digital footprint can cost you a job — even years later!
🔒 Staying Safe Online
There are three main risks online you need to know: Content (what you see), Contact (who talks to you), and Conduct (how you behave).
| Risk Type | Example | How to Stay Safe |
|---|---|---|
| Content | Inappropriate websites, violent images | Use filter software, tell a trusted adult |
| Contact | Strangers messaging you, grooming | Set accounts to private, never meet strangers alone |
| Conduct | Cyberbullying, sharing others' photos | Treat others as you'd want to be treated |
📘 Key Term: Cyberbullying
Using technology to deliberately harm, harass or embarrass someone. If it happens to you: don't reply, save screenshots, block the person, and report to a trusted adult.
🔑 Creating Strong Passwords
A strong password is your first line of defence. A strong password should be: at least 12 characters long, contain uppercase and lowercase letters, numbers AND symbols, and should be unique for each account.
💡 Password Tip: Use a Passphrase!
Instead of password123, try something like
Gr33n!Elephant$Dance7 — three random words with
numbers and symbols. Much harder to crack, much easier to
remember.
🌐 The Internet vs the World Wide Web
📘 Key Term: The Internet
A global network of interconnected computers that communicate using agreed protocols. The Internet is the physical infrastructure — the wires, cables, satellites and routers.
📘 Key Term: The World Wide Web (WWW)
A collection of linked web pages and resources, accessed through the Internet using a web browser. The WWW is a service that runs on top of the Internet.
The Internet vs the World Wide Web
Physical network of computers
Web pages on the Internet
Think of it like this: the Internet is the road network. The WWW is the delivery service using those roads.
✏️ Activity 1 — Safe or Unsafe?
For each scenario below, decide if it is SAFE or UNSAFE and explain why:
- You receive a friend request from someone you don't know.
- You use the same password for your email and gaming accounts.
- You see upsetting content online and tell a trusted adult.
- You share your home address in a public forum to win a prize.
- You set your social media profile to "Private".
🎯 Quick Quiz — Safe Practice
Q1. What is a digital footprint?
Q2. What is the MAIN difference between the Internet and the WWW?
✅ Chapter Summary
- Your digital footprint is permanent — think before you post.
- The three C's of online risk: Content, Contact, Conduct.
- Use strong, unique passwords — try a passphrase.
- The Internet is the physical network; the WWW is a service on it.
- If something makes you uncomfortable online → tell a trusted adult.
💭 Preparation Questions
- If you write a song, who owns it?
- Is it okay to copy an image from Google and use it in your homework?
- What does "giving credit" mean? Why is it important?
🎯 Learning Objectives
- Understand what copyright is and why it exists
- Know the difference between digital piracy and plagiarism
- Understand Creative Commons licensing
- Be able to reference sources correctly
©️ Copyright
📘 Key Term: Copyright
A legal right that automatically protects creators of original work — including music, writing, software, images and video. Copyright means only the creator (or people they permit) can copy, distribute or perform their work.
📘 Key Term: Digital Piracy
Illegally downloading, copying or distributing copyrighted digital content (music, films, software, games) without permission. This is a criminal offence.
📘 Key Term: Plagiarism
Presenting someone else's work or ideas as your own without giving them credit. This includes copying text, code or images without attribution.
| Term | What it means | Example |
|---|---|---|
| Copyright | Legal ownership of creative work | A musician owns their songs |
| Piracy | Illegally copying/distributing work | Downloading a film without paying |
| Plagiarism | Copying without giving credit | Submitting someone else's essay as yours |
| Fair Use | Limited use of copyright material for education | Using a quote in an essay with citation |
✏️ Activity — Piracy or Not?
Decide whether each scenario involves piracy, plagiarism, both, or neither:
-
You stream a film on Netflix that you pay for.
Neither — streaming with a valid subscription is legal.
-
You download a song without paying using a torrent site.
Piracy — downloading copyrighted music without permission is illegal.
-
You copy three paragraphs from Wikipedia into your essay
without any reference.
Plagiarism — you must reference your sources even if the content is freely available.
-
You share a cracked version of Photoshop with your friends.
Piracy — distributing cracked (illegally modified) software is copyright infringement.
✅ Chapter Summary
- Copyright protects creators' work automatically from the moment it is made.
- Piracy = illegal copying of digital content. Plagiarism = copying without credit.
- Always reference your sources — give credit to the original creator.
- Creative Commons licences let creators share work with specific permissions.
💭 Preparation Questions
- How does your phone connect to the internet at home? At school?
- What is a router and what does it do?
- Have you noticed that videos sometimes buffer? Why does that happen?
🔌 Wired vs Wireless
| Feature | Wired (Ethernet) | Wireless (Wi-Fi) |
|---|---|---|
| Speed | Very fast, consistent | Can vary (signal interference) |
| Security | More secure (physical cable needed) | Less secure (signal can be intercepted) |
| Mobility | Device must stay connected to cable | Move freely within range |
| Cost | Requires cable installation | Easier to set up, no cables |
📦 How Data Travels — Packet Switching
When you send data across the internet (a photo, a message, a webpage), it doesn't travel as one big chunk. Instead, it is broken into small pieces called packets.
📘 Key Term: Packet
A small chunk of data sent across a network. Each packet contains: the data itself, the sender's IP address, the receiver's IP address, and a sequence number (so packets can be reassembled in order).
How a message travels as packets
Split into packets
Direct each packet
Packets reassembled
📘 Key Term: IP Address
A unique numerical label (like a home address) given to every
device on a network. IPv4 looks like: 192.168.1.1.
IPv6 is longer to support more devices.
📘 Key Term: Bandwidth & Latency
Bandwidth — the maximum amount of data
transmitted per second (like the width of a pipe).
Latency
— the delay between sending and receiving data (like how long
the water takes to arrive).
🎯 Quick Quiz — Networking
Q1. What is a packet?
Q2. Which of these is an advantage of a WIRED connection over Wi-Fi?
✅ Chapter Summary
- Wired connections are faster and more secure; wireless offers more mobility.
- Data is broken into packets and routed independently across the internet.
- Every device has a unique IP address.
- Bandwidth = how much data can flow; Latency = how fast it arrives.
💭 Preparation Questions
- How many digits does the denary (normal) number system have?
- Why do you think computers use binary rather than denary?
- What is a bit? What is a byte?
🔢 The Binary Number System
Computers use binary — a base-2 number system — because electronic circuits are either ON (1) or OFF (0). Everything stored in a computer: numbers, text, images, sound — is ultimately stored as binary.
📘 Key Terms: Bit and Byte
Bit — a single binary digit (0 or 1). The
smallest unit of data.
Byte — a group of 8 bits. Can represent 256
different values (2⁸).
Binary Place Values
8-bit place value table
10101010 = 128+32+8+2 = 170
✏️ Activity — Binary Conversion
Convert these binary numbers to denary. Use the place value table above!
-
00001111
8+4+2+1 = 15
-
01010101
64+16+4+1 = 85
-
11111111
128+64+32+16+8+4+2+1 = 255
-
Convert denary 42 to binary.
32+8+2 = 42 → 00101010
🔤 ASCII & Unicode
📘 Key Term: ASCII
American Standard Code for Information Interchange. Assigns a number (0–127) to each character so computers can store text. 'A'=65, 'a'=97, '0'=48.
📘 Key Term: Unicode
An extended character encoding system that supports virtually all world languages plus emojis. Uses up to 32 bits per character — over 140,000 characters total.
| Character | ASCII (Decimal) | Binary |
|---|---|---|
| A | 65 | 01000001 |
| B | 66 | 01000010 |
| a | 97 | 01100001 |
| 0 | 48 | 00110000 |
| Space | 32 | 00100000 |
🚀 More Activity — Decode the Message!
Use the ASCII table to decode: 72 101 108 108 111
✅ Chapter Summary
- Computers use binary (base-2) because circuits are ON or OFF.
- 1 bit = one 0 or 1. 8 bits = 1 byte = 256 possible values.
- ASCII maps numbers to characters (A=65). Unicode extends this to all world languages.
- Binary place values (right to left): 1, 2, 4, 8, 16, 32, 64, 128.
💭 What Do You Already Know?
- What is a pixel? Where does the word come from?
- Why do photos sometimes look "blocky" when zoomed in?
- What's the difference between a JPG and an SVG file?
🎯 Learning Objectives
- Explain the difference between bitmap and vector images
- Calculate image file sizes using the formula
- Understand colour depth and its effect on quality and file size
- Perform binary addition including carries
🖼️ Bitmap vs Vector Images
| Feature | Bitmap (Raster) | Vector |
|---|---|---|
| Made of | Grid of pixels | Mathematical shapes (points, lines) |
| Scaling | Loses quality (pixelates) | Scales perfectly at any size |
| File size | Usually larger | Usually smaller |
| Best for | Photos, complex images | Logos, diagrams, icons |
| Formats | JPEG, PNG, BMP, GIF | SVG, PDF, AI |
📏 Calculating Image File Size
📘 Formula: Image File Size
File size (bits) = Width × Height × Colour Depth
Then ÷ 8 for bytes, ÷ 1024 for KiB, ÷ 1024 again for MiB.
✏️ Activity — File Size Calculations
-
An image is 400×300 pixels with 24-bit colour depth. Calculate
the file size in KiB.
400 × 300 × 24 = 2,880,000 bits ÷ 8 = 360,000 bytes ÷ 1024 = ≈351.6 KiB
-
A 1920×1080 image uses 8-bit colour. What is the file size in
MiB?
1920 × 1080 × 8 = 16,588,800 bits ÷ 8 = 2,073,600 bytes ÷ 1024 ÷ 1024 = ≈1.98 MiB
➕ Binary Addition
📘 Binary Addition Rules
0+0=0 · 0+1=1 · 1+0=1 · 1+1=10 (write 0, carry 1) · 1+1+1=11 (write 1, carry 1)
✏️ Activity — Binary Addition
-
0110 + 0011 =
1001 (6+3=9) ✓
-
01011 + 00110 =
10001 (11+6=17) ✓
✅ Chapter Summary
- Bitmap images use pixels; Vector images use mathematical shapes.
- File size = Width × Height × Colour Depth (in bits).
- More colour depth = better quality but larger file size.
- Binary addition: 1+1 = 10 (carry the 1).
📦 Storage Units
| Unit | Symbol | Equal to |
|---|---|---|
| Bit | b | A single 0 or 1 |
| Byte | B | 8 bits |
| Kibibyte | KiB | 1,024 bytes |
| Mebibyte | MiB | 1,024 KiB |
| Gibibyte | GiB | 1,024 MiB |
🗜️ Compression & RLE
📘 Key Term: Lossless Compression
Reducing file size WITHOUT permanently losing any data. The original file can be perfectly reconstructed. Example: ZIP, PNG, RLE.
📘 Key Term: Run Length Encoding (RLE)
A lossless compression method that replaces consecutive repeated
values with a count+value pair.
Example: AAAABBBCC → 4A 3B 2C
✏️ Activity — Apply RLE
Compress the following using RLE:
-
WWWWWBBBWW
5W 3B 2W — saved 10→6 values!
-
AABBBBBAAAC
2A 5B 3A 1C
✅ Chapter Summary
- Storage goes: bit → byte → KiB → MiB → GiB (each ×1024).
- Lossless compression reduces size with no data loss.
- RLE replaces repeated runs with count+value — great for simple images.
💭 Preparation Questions
- Have you used a spreadsheet before? What did you use it for?
- What is the difference between a formula and a function?
- Why might you use a chart to present data instead of a table?
📐 Formulae vs Functions
| Type | What it is | Example |
|---|---|---|
| Formula | A calculation you write yourself, starting with = | =A1+B1+C1 |
| Function | A pre-built formula with a name | =SUM(A1:A10) |
📘 Key Functions to Know
=SUM(range) — adds all values ·
=AVERAGE(range) — calculates mean
=MAX(range) — finds highest ·
=MIN(range) — finds lowest
=COUNT(range) — counts cells with numbers
· =IF(test,yes,no) — conditional
📈 Charts & Graphs
| Chart Type | Best Used For |
|---|---|
| Bar/Column Chart | Comparing categories side by side |
| Line Graph | Showing trends over time |
| Pie Chart | Showing proportions of a whole |
| Scatter Graph | Showing relationships between two variables |
🎯 Quick Quiz — Spreadsheets
Q1. Which function would you use to find the total of cells A1 to A20?
✅ Chapter Summary
- Formulae start with = and perform calculations. Functions are built-in formulae (SUM, AVERAGE, IF).
- Sort data ascending (A→Z) or descending (Z→A). Filter shows only rows matching criteria.
- Choose your chart type to match what the data is showing.
🖥️ Types of Software
| Type | Purpose | Examples |
|---|---|---|
| System Software | Manages hardware and resources | Windows, macOS, Linux |
| Application Software | Lets users complete specific tasks | Word, Chrome, Spotify |
| Utility Software | Maintains and protects the system | Anti-malware, disk cleaner, backup |
🔣 Logic Operators
📘 AND, OR, NOT
AND — both conditions must be True → result is
True
OR — at least one condition must be True →
result is True
NOT — reverses: NOT True = False, NOT False =
True
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| True | True | True | True | False |
| True | False | False | True | False |
| False | True | False | True | True |
| False | False | False | False | True |
🛡️ Cyber Security Threats
| Threat | What it is | Defence |
|---|---|---|
| Malware | Malicious software (virus, ransomware, spyware) | Anti-malware software |
| Phishing | Fake emails/sites stealing login details | Awareness training, check URLs |
| Eavesdropping | Intercepting data on a network | Encryption (HTTPS) |
| Brute Force | Trying millions of passwords | Strong passwords, account lockout |
✅ Chapter Summary
- Three types of software: System, Application, Utility.
- Logic operators: AND (both true), OR (one true), NOT (reverses).
- Wireless tech: Wi-Fi (~100m), Bluetooth (~10m), NFC (~4cm).
- Defend against threats with: anti-malware, encryption, strong passwords, awareness.
💭 Preparation Questions
- How would you find a specific name in an unsorted list of 1000 names?
- What strategies do you use to sort things in everyday life?
- What is an algorithm? Give an everyday example.
🎯 Learning Objectives
- Trace through a linear search algorithm step by step
- Trace through bubble sort showing all passes and swaps
- Understand the concept of abstraction
- Evaluate the efficiency of algorithms
🔍 Linear Search
📘 Key Term: Linear Search
Checks each item in a list one by one from the start until the target is found or the end is reached. Works on unsorted and sorted lists.
Linear search for 7 in [3, 8, 1, 7, 5]
Found at index 3 after 4 comparisons.
🔃 Bubble Sort
📘 Key Term: Bubble Sort
Repeatedly compares adjacent pairs of items and swaps them if out of order. Larger values "bubble" to the end. Needs n-1 passes for n items in the worst case.
✏️ Activity — Trace Bubble Sort
Sort the list [5, 3, 8, 1] using bubble sort. Show each pass:
Pass 2: [3,5]→no swap; [5,1]→swap→[3,1,5,8]; [5,8]→no swap → [3,1,5,8]
Pass 3: [3,1]→swap→[1,3,5,8]; rest no swap → [1,3,5,8] ✓ Sorted!
🎯 Quick Quiz
Q1. What is the worst case for a linear search on a list of 100 items?
✅ Chapter Summary
- Linear search checks items one by one — simple but slow for large lists.
- Bubble sort compares adjacent pairs and swaps — needs multiple passes.
- Abstraction = hiding unnecessary detail, focusing on what matters.
🎵 Digitising Sound
📘 Key Term: Sampling
Measuring the amplitude (height) of a sound wave at regular time intervals to create a digital representation. More samples per second = more accurate recording.
| Term | What it means | Effect of increasing |
|---|---|---|
| Sample Rate | Samples per second (Hz) | Better quality, larger file |
| Bit Depth | Bits per sample | More amplitude levels, better dynamic range, larger file |
💜 Did You Know?
CD audio quality is 44,100 Hz sample rate and 16-bit depth. Human hearing can detect frequencies up to about 20,000 Hz — so 44,100 Hz captures everything we can hear!
💿 Storage Devices vs Storage Media
| Term | Definition | Example |
|---|---|---|
| Storage Device | Hardware that reads/writes data | Hard drive unit, USB drive |
| Storage Media | Physical material data is stored on | Magnetic disk, flash chip, optical disc |
| Type | Speed | Capacity | Cost | Durability |
|---|---|---|---|---|
| HDD | Medium | High | Cheap | Lower (moving parts) |
| SSD | Very fast | Medium-High | More expensive | Higher (no moving parts) |
| Optical (DVD/Blu-ray) | Slow | Low-Medium | Very cheap | Scratches easily |
✅ Chapter Summary
- Sound is digitised by sampling — measuring amplitude at regular intervals.
- Higher sample rate and bit depth = better quality but larger file size.
- HDD uses magnetic spinning disks; SSD uses flash chips — faster but costlier.
💭 Preparation Questions
- What happens when you turn on a computer?
- What does RAM stand for? What does it do?
- Why does your computer slow down when you have many programs open?
⚡ The Fetch-Decode-Execute Cycle
📘 Key Term: Fetch-Decode-Execute Cycle
The continuous process the CPU follows:
1. Fetch — Get the next instruction from RAM
(using the Program Counter)
2. Decode — The Control Unit works out what the
instruction means
3. Execute — The ALU carries out the
instruction
The CPU cycle
Get instruction from RAM
Work out what it means
Carry out the instruction
🧠 Memory: RAM vs ROM
| Feature | RAM | ROM |
|---|---|---|
| Full name | Random Access Memory | Read Only Memory |
| Volatile? | Yes — data lost when power off | No — data retained permanently |
| Purpose | Holds current programs/data | Stores start-up instructions (BIOS/UEFI) |
| Speed | Very fast | Fast |
💻 High-Level vs Low-Level Languages
| Feature | High-Level (e.g. Python) | Low-Level (Assembly/Machine Code) |
|---|---|---|
| Readability | Close to English — easy to read | Difficult — uses mnemonics or binary |
| Portability | Works on many systems | Hardware-specific |
| Translation | Needs compiler or interpreter | Machine code runs directly |
| Speed | Slightly slower | Fastest possible |
✅ Chapter Summary
- The CPU follows the Fetch-Decode-Execute cycle continuously.
- RAM is volatile (fast, temporary); ROM is non-volatile (stores start-up code).
- More RAM → more programs run simultaneously without slowing down.
- High-level languages (Python, Java) are portable and readable; low-level is fast but complex.
🌐 Types of Network
| Network | Full Name | Coverage | Example |
|---|---|---|---|
| PAN | Personal Area Network | Within a few metres | Bluetooth headphones |
| LAN | Local Area Network | One building/site | School network |
| WAN | Wide Area Network | Large geographic area | The Internet |
🤝 Software Licensing
| Type | What it means | Example |
|---|---|---|
| Proprietary | Closed source — owned by company, can't modify | Microsoft Windows, Adobe Photoshop |
| Open Source | Source code is public — free to use, modify, share | Linux, Firefox, LibreOffice |
| Freeware | Free to use but source code not available | Skype, Zoom (free tier) |
⚖️ The Digital Divide
📘 Key Term: Digital Divide
The gap between people who have access to digital technology and the internet and those who do not — due to poverty, location, age or disability.
🚀 Discussion Activity — Ethics of Technology
Think about and discuss these questions with a partner:
- Who is most likely to be affected by the digital divide and why?
- Should social media companies be responsible for content posted by users?
- Is it ethical for companies to collect your data to show you targeted adverts?
- What can governments do to close the digital divide?
✅ Chapter Summary
- PAN (Bluetooth range) → LAN (building) → WAN (global, e.g. Internet).
- Open source = free and modifiable. Proprietary = paid, closed source.
- The digital divide creates inequality in education, jobs and access to services.
💭 Preparation Questions
- How does your school store information about students?
- What's the difference between a row and a column in a table?
- If you were designing a student database, what fields would you include?
🗂️ Database Structure
| Term | Definition | Example |
|---|---|---|
| Table | A collection of related data in rows and columns | Students table |
| Record | A single row — one complete entry | One student's details |
| Field | A single column — one category of data | StudentID, Name, Year |
| Primary Key | A unique field that identifies each record | StudentID |
| Foreign Key | A field linking to another table's primary key | ClassID in a Students table |
Example: Students Database Table
| StudentID 🔑 | FirstName | LastName | Year | ClassID 🔗 |
|---|---|---|---|---|
| 001 | Amara | Osei | 9 | 9A |
| 002 | James | Patel | 9 | 9B |
| 003 | Sofia | Chen | 8 | 8A |
🔑 = Primary Key · 🔗 = Foreign Key
🔎 Queries
📘 Key Term: Query
A request to retrieve, filter or update data in a database. Written in SQL (Structured Query Language).
SELECT FirstName, LastName FROM Students WHERE Year = 9 ORDER BY LastName;
✏️ Activity — Write a Query
Using the Students table above, write SQL to find all students in class 9A.
SELECT * FROM Students WHERE ClassID = '9A';This would return: Amara Osei (001).
✅ Chapter Summary
- Databases store data in tables (rows=records, columns=fields).
- Primary key uniquely identifies each record. Foreign key links to another table.
- Queries (SQL) retrieve specific data from a database.
🏗️ HTML Structure
<!DOCTYPE html> <html lang="en"> <head> <title>My Page</title> <meta charset="UTF-8"/> </head> <body> <h1>Hello World!</h1> <p>This is my first web page.</p> </body> </html>
| Tag | Purpose | Example |
|---|---|---|
<h1>–<h6> |
Headings (h1 biggest) | <h1>Title</h1> |
<p> |
Paragraph | <p>Text</p> |
<a href=""> |
Hyperlink |
<a href="page.html">Click</a>
|
<img src=""> |
Image | <img src="pic.jpg" alt="desc"> |
<ul> <li> |
Unordered list |
<ul><li>Item</li></ul>
|
<strong> |
Bold text | <strong>Bold</strong> |
✏️ Activity — Build a Page
Write HTML to create a page about your favourite subject that includes:
- A heading (h1)
- Two paragraphs
- An unordered list of three facts
- A link to a relevant website
<h1>Why I Love Computing</h1> <p>Computing is fascinating because...</p> <p>Some key topics I enjoy are...</p> <ul> <li>Programming in Python</li> <li>How networks work</li> <li>Designing databases</li> </ul> <a href="https://www.bbc.co.uk/bitesize">Revise on BBC Bitesize</a>
✅ Chapter Summary
- HTML uses tags to structure web content — most tags have an opening and closing version.
- <head> = metadata (title, charset). <body> = visible content.
- Key tags: h1–h6, p, a, img, ul, li, strong, em.
- Metadata in <head> is not visible to users but is used by browsers and search engines.
💭 Before You Start Python
- Python is a high-level programming language — it reads like English.
- You write Python in an IDE (e.g. Thonny, IDLE, VS Code, or online at replit.com).
-
Python is case-sensitive:
Nameandnameare different variables! - Indentation matters — use 4 spaces (or Tab) consistently.
Your First Program
print("Hello, World!")
That's it! print() is a function —
it displays whatever is inside the brackets. Text must be in
quotes.
print("My name is Amara") print("I am in Year 9") print(42) # Numbers don't need quotes print(3.14) # Decimal (float) print(10 + 5) # Calculations work too!
Variables
A variable is a named container that stores a value. You can change what's in it.
# Creating variables name = "Kofi" # String (text) age = 14 # Integer (whole number) height = 1.72 # Float (decimal) is_student = True # Boolean (True or False) print(name) print(age) print("Hello,", name, "— you are", age, "years old.")
| Data Type | What it stores | Example |
|---|---|---|
| int | Whole numbers | age = 14 |
| float | Decimal numbers | height = 1.72 |
| str | Text (in quotes) | name = "Kofi" |
| bool | True or False | is_student = True |
Getting Input from the User
name = input("What is your name? ") print("Hello,", name, "!") age = int(input("How old are you? ")) # int() converts text to number print("Next year you will be", age + 1)
⚠️ Important: input() always returns a STRING
If you want to do maths with user input, you must convert it:
int(input(...)) for whole numbers or
float(input(...)) for decimals. Otherwise you'll
get an error!
🏆 Starter Challenge
Write a program that asks the user for their name and age, then prints: "Hi [name]! You were born in [year]." (calculate the year from age)
name = input("What is your name? ")
age = int(input("How old are you? "))
birth_year = 2025 - age
print("Hi", name + "! You were born in", birth_year, ".")
Basic if / else
score = int(input("Enter your score: ")) if score >= 60: print("Pass! Well done 🎉") else: print("Not quite — keep practising!")
💡 The Colon and Indentation
The if line ends with a colon :. The
code inside the if block MUST be indented (4 spaces). Python
uses indentation to know which code belongs inside the block.
Multiple Conditions with elif
score = int(input("Enter score (0-100): ")) if score >= 90: grade = "A*" elif score >= 80: grade = "A" elif score >= 70: grade = "B" elif score >= 60: grade = "C" else: grade = "Below pass" print("Your grade:", grade)
🏆 Developing Challenge
Modify the grade program to also print an encouraging message with each grade. For example, A* → "Outstanding!" and Below pass → "Don't give up!"
Comparison & Boolean Operators
| Operator | Meaning | Example |
|---|---|---|
== |
Equal to | x == 5 |
!= |
Not equal to | x != 0 |
> < |
Greater/Less than | age > 18 |
>= <= |
Greater/Less than or equal | score >= 60 |
and |
Both conditions true | x > 0 and x < 10 |
or |
At least one true | x == 0 or x == 1 |
not |
Reverses condition | not x > 5 |
age = int(input("Age: ")) has_ticket = input("Do you have a ticket? (yes/no): ") if age >= 16 and has_ticket == "yes": print("Welcome! Enjoy the concert 🎵") elif has_ticket != "yes": print("Sorry, you need a ticket.") else: print("Sorry, you must be 16 or over.")
🎯 Python Quiz — Selection
Q1. What does elif stand for?
Q2. In Python, what does != mean?
The for loop
A for loop repeats a block of code a
fixed number of times.
# Count from 0 to 4 for i in range(5): print("Count:", i)
# Count from 1 to 10 in steps of 2 for num in range(1, 11, 2): print(num) # Count DOWN from 5 to 1 for i in range(5, 0, -1): print(i)
The while loop
A while loop repeats as long as a condition is True
— useful when you don't know how many times to repeat.
count = 1 while count <= 5: print("Lap", count) count += 1 # Same as count = count + 1 print("Race finished!")
password = "secret123" attempt = "" tries = 0 while attempt != password and tries < 3: attempt = input("Enter password: ") tries += 1 if attempt == password: print("Access granted! ✅") else: print("Too many attempts. Locked! 🔒")
⚠️ Avoid Infinite Loops!
If the while condition never becomes False, the loop runs forever (infinite loop). Always make sure something inside the loop eventually makes the condition False — e.g. incrementing a counter.
Loops + Decisions Combined
number = int(input("Which times table? ")) for i in range(1, 13): result = number * i if result % 2 == 0: # % is modulo (remainder) print(number, "×", i, "=", result, "(even)") else: print(number, "×", i, "=", result, "(odd)")
🏆 Secure Challenge — FizzBuzz
Print numbers 1–30. For multiples of 3 print "Fizz", multiples of 5 print "Buzz", multiples of both print "FizzBuzz", otherwise print the number.
for i in range(1, 31):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
String Operations
name = "Computing" # Concatenation (joining strings) print("I love " + name + "!") # Length print(len(name)) # 9 # Indexing — first character is index 0 print(name[0]) # C print(name[-1]) # g (last character) # Slicing [start:stop] — stop is NOT included print(name[0:4]) # Comp print(name[4:]) # uting print(name[::-1]) # gnitupmoC (reversed!)
Useful String Methods
text = " Hello, World! " print(text.upper()) # HELLO, WORLD! print(text.lower()) # hello, world! print(text.strip()) # Removes spaces: "Hello, World!" print(text.replace("World", "Python")) # Hello, Python! print(text.count("l")) # 3 print("," in text) # True # Split into a list of words words = "one two three".split() print(words) # ['one', 'two', 'three']
f-strings (Formatted Strings)
f-strings make it easy to include variables inside strings — much cleaner than concatenation!
name = "James" score = 87 grade = "A" # Old way (messy): print("Hello " + name + ", you scored " + str(score) + ", grade: " + grade) # New way with f-string (clean!): print(f"Hello {name}, you scored {score}, grade: {grade}") print(f"Double your score: {score * 2}") # Can do maths inside {}
Creating and Accessing Lists
# Creating a list fruits = ["apple", "banana", "cherry", "mango"] scores = [85, 72, 91, 68, 77] # Accessing by index (starts at 0) print(fruits[0]) # apple print(fruits[-1]) # mango (last item) print(len(fruits)) # 4 # Modifying a list fruits[1] = "blueberry" # Replace banana fruits.append("orange") # Add to end fruits.remove("cherry") # Remove by value print(fruits)
Looping through Lists
scores = [85, 72, 91, 68, 77] # Method 1: loop through values directly for score in scores: print(f"Score: {score}") # Method 2: loop with index using enumerate for i, score in enumerate(scores): print(f"Student {i+1}: {score}") # Useful list operations print("Total:", sum(scores)) print("Average:", sum(scores) / len(scores)) print("Highest:", max(scores)) print("Lowest:", min(scores))
Linear Search in Python
def linear_search(lst, target): for i in range(len(lst)): if lst[i] == target: return i # Return the index where found return -1 # -1 means not found numbers = [15, 3, 42, 7, 19] result = linear_search(numbers, 42) if result != -1: print(f"Found at index {result}") else: print("Not found")
Defining and Calling Functions
# PROCEDURE — does something, returns nothing def greet(name): print(f"Hello, {name}! Welcome to TheShelf.") greet("Amara") # Call the procedure greet("James") # FUNCTION — does something AND returns a value def calculate_area(width, height): area = width * height return area # Sends the result back room_area = calculate_area(5, 8) print(f"Area: {room_area} m²")
Parameters, Arguments & Default Values
# Parameters with default values def power(base, exponent=2): # default exponent is 2 return base ** exponent print(power(3)) # 3² = 9 print(power(2, 10)) # 2¹⁰ = 1024 print(power(5, 3)) # 5³ = 125
Global vs Local Variables & Scope
total = 100 # Global variable — accessible everywhere def add_to_total(amount): local_result = total + amount # Can READ global return local_result # local_result only exists inside here print(add_to_total(50)) # 150 # print(local_result) # ERROR! Can't access local variable outside function
💡 Scope Rule
Local variables only exist inside the function where they are created. Global variables are created outside functions and can be read anywhere. Prefer passing values as parameters rather than using global variables — it makes your code cleaner.
Project 1 — Quiz Game
# A complete quiz game using all key concepts def ask_question(question, correct_answer): """Ask a question and return True if correct.""" answer = input(question + " ").strip().lower() if answer == correct_answer.lower(): print("✅ Correct!") return True else: print(f"❌ Wrong — the answer was: {correct_answer}") return False # Question bank — list of [question, answer] pairs questions = [ ["What does CPU stand for?", "central processing unit"], ["How many bits in a byte?", "8"], ["What does RAM stand for?", "random access memory"], ["What is binary? (base-? number system)", "base-2"], ] score = 0 name = input("Enter your name: ") print(f"\nWelcome, {name}! Let's test your computing knowledge.\n") for i, q in enumerate(questions): print(f"Question {i+1}/{len(questions)}:") if ask_question(q[0], q[1]): score += 1 print() percentage = round(score / len(questions) * 100) print(f"--- Results for {name} ---") print(f"Score: {score}/{len(questions)} ({percentage}%)") if percentage >= 75: print("🏆 Excellent work!") elif percentage >= 50: print("👍 Good effort — keep revising!") else: print("📚 Review your notes and try again!")
Project 2 — Bubble Sort Implementation
def bubble_sort(data): n = len(data) passes = 0 swaps = 0 for i in range(n - 1): passes += 1 swapped = False for j in range(n - 1 - i): if data[j] > data[j + 1]: data[j], data[j + 1] = data[j + 1], data[j] swapped = True swaps += 1 print(f"After pass {passes}: {data}") if not swapped: # Optimisation: stop if no swaps print("No swaps — already sorted! Stopping early.") break print(f"\nSorted: {data}") print(f"Total passes: {passes}, Total swaps: {swaps}") return data my_list = [64, 34, 25, 12, 22, 11] bubble_sort(my_list)
Project 3 — Student Grade Manager
def get_grade(score): if score >= 90: return "A*" elif score >= 80: return "A" elif score >= 70: return "B" elif score >= 60: return "C" else: return "U" def display_report(students): print("\n{'='*40}") print(f"{'Name':15} {'Score':8} {'Grade'}") print("-" * 30) for s in students: print(f"{s['name']:15} {s['score']:8} {s['grade']}") scores = [s['score'] for s in students] print(f"\nClass average: {sum(scores)/len(scores):.1f}") print(f"Highest: {max(scores)} | Lowest: {min(scores)}") # Main program students = [] print("=== Student Grade Manager ===") while True: name = input("\nEnter student name (or 'done' to finish): ") if name.lower() == "done": break score = int(input(f"Enter {name}'s score (0-100): ")) grade = get_grade(score) students.append({"name": name, "score": score, "grade": grade}) print(f"Added: {name} — {score} ({grade})") if students: display_report(students)
🚀 Final Python Challenges
- Number Guessing Game — Computer picks a random number (1–100), user guesses, program gives "too high"/"too low" hints. Count attempts.
- Caesar Cipher — Encrypt a message by shifting each letter by n positions. Then write the decrypt function too.
- Shopping Basket — Allow user to add/remove items and quantities. Calculate subtotal, VAT (20%) and total.
- Contacts Book — Store names and phone numbers in a dictionary. Add search, add, and delete functions.
🐍 Python Journey Complete!
- ✅ Basics — print, variables, data types, input/output
- ✅ Selection — if, elif, else, comparison operators
- ✅ Loops — for (range), while, nested loops
- ✅ Strings — indexing, slicing, methods, f-strings
- ✅ Lists — create, access, modify, loop, search, sort
- ✅ Functions — procedures, functions, parameters, return, scope
- ✅ Projects — quiz game, bubble sort, grade manager
🧠 Can You Answer These? (Click to reveal each answer)
You've reached the end!
You've covered every topic from Years 7, 8 and 9 in one complete booklet. Keep practising, use the flashcards, and tackle the exam prep — you've got this!