Welcome, young builder! This is the first module of your journey to become an Advanced Software Engineer. But wait – what does “advanced” mean? It does not mean you have to know everything. It means you learn to think in a special way – like a detective, a builder, and a storyteller all at once!
In this module, we will learn how to break big problems into small pieces, plan before we code, and test our work so that it works perfectly. We will use lots of stories, pictures, and everyday examples. By the end, you will feel like a real software engineer – even if you have never written a single line of code!
Let’s begin our adventure with a fun story.
After this module, you will be able to:
Tunde was turning 10, and his mum gave him a giant puzzle – 500 pieces! At first, Tunde felt excited. But when he opened the box, he saw a mountain of tiny, mixed‑up pieces. “This is too much!” he cried.
His older sister, Ada, who was learning to be a software engineer, smiled. “Don’t look at all 500 pieces at once,” she said. “Let’s think like an engineer.”
Ada showed Tunde how to sort the pieces by colour. Then they made small groups: sky, trees, house, and people. They worked on one group at a time. After each group, they checked if the pieces fit. When they finished, they had built a beautiful picture of a beach.
Tunde learned a big lesson: big problems are just many small problems put together. That is exactly how software engineers work – they break huge apps into tiny parts, build each part, and then connect them.
Now, let’s learn the secrets that Ada used!
Definition: A software engineer is a person who uses special thinking skills to create computer programs, apps, and games.
Why is it important? Because every app you use – from games to school learning tools – was built by a software engineer.
Simple explanation: Imagine you are a chef. A chef reads a recipe and cooks food. A software engineer reads a “recipe” (called code) and builds a program. But the best engineers do more than just code – they plan, test, and fix things.
Real‑life example: When you play a football video game, a software engineer designed how players run, kick, and score.
School example: Your teacher uses a computer to take attendance. A software engineer built that attendance system.
Home example: The app your parents use to order food was made by software engineers.
Nigerian example: The e‑Naira app – Nigeria’s digital money – was built by a team of software engineers.
Illustration (ASCII):
+------------------+
| Software Engineer|
+--------+---------+
|
+--------v---------+
| Plan the project |
+--------+---------+
|
+--------v---------+
| Write the code |
+--------+---------+
|
+--------v---------+
| Test and fix |
+--------+---------+
|
+--------v---------+
| Launch! 🚀 |
+------------------+
Mini summary: A software engineer is a builder of digital things. They plan, build, test, and improve.
Definition: The engineering mindset is a way of thinking that is curious, logical, and patient.
Why is it important? Because with this mindset, you never give up when things get hard – you just try a new way!
Simple explanation: Think of a detective solving a mystery. They ask questions, gather clues, and test ideas. An engineer does the same with software.
Real‑life example: When a game crashes, an engineer does not panic. They ask “Why?” and look for clues.
School example: If your math answer is wrong, you check your steps. That’s the engineering mindset.
Home example: When your remote control stops working, you check the batteries, then the sensor – you test.
Nigerian example: In Lagos, traffic is heavy. Engineers design traffic‑light systems that change timing to reduce jams – they test different timings.
Illustration:
Problem → Ask "Why?" → Think of ideas → Try one → Check if it works → If not, try another.
Mini summary: The engineering mindset means staying curious and never giving up.
Definition: Decomposition is breaking a big problem into small, easy‑to‑handle pieces.
Why is it important? Because small pieces are easier to understand and fix.
Simple explanation: It’s like eating a big pizza – you can’t eat it in one bite, so you cut slices.
Real‑life example: Building a house: you don’t build the whole thing at once. You lay the foundation, then walls, then roof.
School example: Writing an essay: you write an introduction, body, and conclusion – not all at once.
Home example: Cleaning your room: pick up toys, then clothes, then books – one step at a time.
Nigerian example: Preparing Jollof rice: you chop onions, blend tomatoes, cook the rice, then mix – each step is a small piece.
Illustration:
Big task: "Build a calculator app"
|
+----+----+----+----+
| | | | |
Add Sub Mul Div Display
Mini summary: Always break big tasks into smaller steps. It makes everything simpler.
Definition: Planning means drawing or writing what you want your program to do before you start typing code.
Why is it important? Because it saves time and prevents mistakes.
Simple explanation: Before you build with Lego, you look at the instructions. That’s planning.
Real‑life example: Architects draw blueprints before building a bridge.
School example: You outline your project before writing the final copy.
Home example: You plan a birthday party – guest list, food, games – before the day.
Nigerian example: Before building a new market in Abuja, planners draw a map of shops and walkways.
Illustration:
Plan (draw) → Code (write) → Test (check) → Finish ✅
Mini summary: Plan first, code second. Planning is like a map for your journey.
Definition: An algorithm is a list of steps to solve a problem, like a recipe for cooking.
Why is it important? Because computers follow algorithms exactly – so we must be clear.
Simple explanation: An algorithm is a set of instructions. If you tell your friend how to tie shoelaces step by step, that is an algorithm.
Real‑life example: A GPS navigation system uses an algorithm to find the shortest route.
School example: The steps to solve a long division problem are an algorithm.
Home example: A washing machine cycle – soak, wash, rinse, spin – is an algorithm.
Nigerian example: Making Zobo drink: boil leaves, add sugar, strain, cool – that’s an algorithm.
Illustration:
1. Start 2. Add water to pot 3. Put pot on fire 4. Add Zobo leaves 5. Boil for 20 minutes 6. Add sugar 7. Strain 8. Cool 9. Serve
Mini summary: An algorithm is a clear, step‑by‑step recipe for the computer.
Definition: Code is a special language that we use to give instructions to a computer.
Why is it important? Because code is how we talk to computers.
Simple explanation: Just as we use English or Yoruba or Hausa to talk to each other, we use code to talk to computers.
Real‑life example: The code for a game tells the computer when to move a character.
School example: A teacher uses a code to create a quiz on the school portal.
Home example: The code in your TV remote tells it to change channels.
Nigerian example: The code behind the Chams identity system helps verify Nigerian citizens.
Illustration:
[Human language] → [Code] → [Computer action] "Jump!" → jump() → character jumps
Mini summary: Code is the language we use to command computers.
Definition: A bug is a mistake in code. Debugging is finding and fixing that mistake.
Why is it important? Because even small bugs can make a program crash.
Simple explanation: It’s like a spelling mistake in a sentence – it changes the meaning.
Real‑life example: If a robot arm is coded to move 10cm but moves 100cm, that’s a bug.
School example: If your calculator gives the wrong answer, there might be a bug in its code.
Home example: If your alarm clock doesn’t ring, maybe the code has a bug.
Nigerian example: A bug in a bank app could show wrong balances – engineers debug it quickly.
Illustration:
Code → Run → ❌ Error → Find bug → Fix → ✅ Works
Mini summary: Bugs are mistakes; debugging is the superpower of fixing them.
Definition: Testing means checking if your program works correctly in all situations.
Why is it important? Because we want our software to be reliable.
Simple explanation: It’s like a teacher checking your homework – they make sure everything is right.
Real‑life example: Before a new car is sold, it is tested on different roads.
School example: After you write an answer, you read it again to check for mistakes.
Home example: You test a new recipe by tasting it before serving guests.
Nigerian example: Before the NIN registration system goes live, engineers test it with dummy data.
Illustration:
Write code → Test with sample data → If fails, fix → Test again → Pass ✅
Mini summary: Always test your work to make sure it works.
Definition: Teamwork means working together with other engineers to build bigger projects.
Why is it important? Because big apps are too large for one person to build alone.
Simple explanation: It’s like a football team – each player has a role, and they pass the ball.
Real‑life example: The Instagram app was built by a team of many engineers.
School example: Group projects – one person researches, one writes, one presents.
Home example: Family members share chores – one cooks, one cleans.
Nigerian example: The Remita payment platform was built by a team of Nigerian engineers.
Illustration:
[Designer] ←→ [Frontend] ←→ [Backend] ←→ [Tester]
all working together
Mini summary: Teamwork makes the dream work – and builds better software.
Definition: The Waterfall model is a step‑by‑step way to build software, where each step must finish before the next begins.
Why is it important? It helps keep projects organized.
Simple explanation: Like building a house – you can’t put the roof on before the walls.
Real‑life example: Building a bridge – first design, then materials, then construction.
School example: Writing a story – first plan, then draft, then edit, then final.
Home example: Making a cake – mix, bake, frost – you can’t frost before baking.
Nigerian example: Building a new school – first get land, then build, then furnish.
Illustration:
Requirements → Design → Code → Test → Deploy
(each step flows down like water)
Mini summary: Waterfall is a linear, step‑by‑step way to build software.
Definition: Agile is a way of working where you build software in small chunks and keep improving.
Why is it important? Because requirements change, and Agile lets you adapt.
Simple explanation: Instead of building the whole thing at once, you build a little, show it, get feedback, and improve.
Real‑life example: A video game releases new levels every few months – that’s Agile.
School example: You write a paragraph, show your teacher, get suggestions, then write the next paragraph.
Home example: Redecorating a room – do one wall, check if you like the colour, then do the next.
Nigerian example: A fintech app releases a basic transfer feature, then adds savings later.
Illustration:
Sprint 1: Build login Sprint 2: Add profile Sprint 3: Add payments (each sprint delivers a working piece)
Mini summary: Agile means build a little, check, improve, repeat.
Definition: A user story is a short, simple description of a feature from the user’s point of view.
Why is it important? It helps us understand what the user actually needs.
Simple explanation: It’s like saying “As a student, I want to see my grades so I know how I’m doing.”
Real‑life example: “As a shopper, I want to add items to a cart so I can buy them.”
School example: “As a pupil, I want to see my timetable so I know which class is next.”
Home example: “As a parent, I want a shopping list so I don’t forget items.”
Nigerian example: “As a farmer, I want to see weather forecasts so I know when to plant.”
Illustration:
As a [user] I want [action] So that [benefit]
Mini summary: User stories keep the focus on the person using the software.
Definition: A prototype is a simple, rough version of your program to test ideas.
Why is it important? It lets you see if your idea works without spending too much time.
Simple explanation: Like drawing a quick sketch before painting a big picture.
Real‑life example: Car designers make clay models before building the real car.
School example: You make a rough draft of your essay before writing the final one.
Home example: You set up the furniture with paper cutouts to see if it fits.
Nigerian example: A startup builds a simple version of a delivery app to test in one area before expanding.
Illustration:
Idea → Draw prototype → Test with users → Improve → Build final
Mini summary: Prototypes are quick drafts that help you test your ideas.
Definition: Documentation is written information about your code – how it works and how to use it.
Why is it important? So that other engineers (and your future self) can understand your code.
Simple explanation: Like leaving a note for your friend explaining how your toy works.
Real‑life example: User manuals for a TV are documentation.
School example: Your notes from class are documentation.
Home example: A recipe card is documentation for cooking.
Nigerian example: The NIMC provides a guide on how to use the NIN portal – that’s documentation.
Illustration:
Code + Comments + User Guide = Good Documentation
Mini summary: Documentation is like a map that helps others navigate your code.
Definition: Ethics means making sure your software is fair, safe, and respects privacy.
Why is it important? Because software affects people’s lives.
Simple explanation: It’s like being a good friend – you don’t share secrets without permission.
Real‑life example: A health app must keep your medical records private.
School example: You don’t copy someone else’s homework – that’s unethical.
Home example: You don’t read your sibling’s diary.
Nigerian example: Nigerian engineers ensure that the e‑Naira app protects users’ financial data.
Illustration:
Build with: - Honesty - Privacy - Fairness - Safety
Mini summary: Good engineers build software that is safe and fair for everyone.
| Word | Simple Definition |
|---|---|
| Software Engineer | A person who builds computer programs. |
| Decomposition | Breaking a big problem into small parts. |
| Algorithm | A step‑by‑step recipe to solve a problem. |
| Code | Instructions written for a computer. |
| Bug | A mistake in code. |
| Debugging | Finding and fixing bugs. |
| Testing | Checking if code works correctly. |
| Agile | Building software in small, flexible steps. |
| Prototype | A rough draft of a program. |
| Documentation | Written info about how code works. |
| Ethics | Doing what is fair and safe in software. |
This module introduces the mindset of software engineering before any coding. Emphasise stories and analogies. Use group discussions to let students share how they break down tasks. Encourage drawing diagrams. The goal is to build confidence and curiosity.
Encourage your child to plan before doing any task – from homework to chores. Ask them: “What are the steps?” Celebrate when they fix something on their own. Relate their activities to engineering – e.g., “You just debugged your lego tower!”
Start
|
v
Identify Problem
|
v
Break into pieces
|
v
Solve each piece
|
v
Combine solutions
|
v
End ✅
| Feature | Waterfall | Agile |
|---|---|---|
| Steps | Linear, one after another | Iterative, in small cycles |
| Flexibility | Rigid – changes are hard | Flexible – changes are easy |
| Testing | At the end | Throughout |
| Best for | Large, stable projects | Fast‑changing projects |
Congratulations! You have completed Module 1. You learned that a software engineer is not just a coder – they are a planner, a tester, a team player, and a problem‑solver. You discovered how to break big problems into small pieces, the importance of algorithms, and how to fix bugs. You also learned about different ways to build software, like Waterfall and Agile, and you thought about ethics and teamwork.
Remember: the most important skill is not memorising code – it’s how you think. You are now ready to start thinking like an advanced software engineer!
Match the term with its definition:
| Term | Definition |
|---|---|
| 1. Algorithm | A. Breaking problems into small parts |
| 2. Bug | B. A mistake in code |
| 3. Decomposition | C. Step‑by‑step recipe |
| 4. Agile | D. Flexible software development |
| 5. Prototype | E. A rough draft |
Answers: 1‑C, 2‑B, 3‑A, 4‑D, 5‑E
Scenario 1: You are building a quiz app for your school. The app should ask questions, check answers, and show a score. How would you break this down into smaller parts? List at least 5 parts.
Scenario 2: Your friend says “I don’t need to plan, I’ll just code.” What would you tell them about the importance of planning?
In groups of 4, choose a simple task (e.g., making a sandwich, planning a school event). Write down the steps (algorithm) for that task. Then, swap with another group and see if they can follow your steps. Discuss any missing details. This shows how clear instructions are crucial in software.
Think of a problem you face daily (e.g., losing your school bag). Write a simple algorithm (5‑10 steps) to solve it. Draw a flowchart using boxes and arrows. Present it to the class.
Build a Paper Prototype: Design a simple app that helps students organise their homework. Draw each screen on paper. Show how a user would add a new homework, mark it as done, and delete it. No coding – just paper and markers!
Write a detailed algorithm (10‑15 steps) for making a cup of tea. Use bullets. Then, ask a family member to follow it exactly. Write down any confusion they have and improve your algorithm.
Think about the school bell system. It rings at specific times. Design a simple system (using steps) that could ring the bell based on the time. Include conditions like “if time is 8:00, ring bell”. Write this as an algorithm with if‑then statements.
Fill‑in‑the‑Blank: 1. programs, 2. decomposition, 3. algorithm, 4. bug, 5. debugging, 6. Agile, 7. prototype, 8. documentation, 9. ethics, 10. Waterfall.
True/False: 1F, 2T, 3F, 4F, 5F, 6T, 7F, 8F, 9T, 10F.
Multiple Choice: 1B, 2B, 3B, 4B, 5B, 6B, 7B, 8B, 9B, 10B, 11A, 12B, 13B, 14B, 15B.
In Module 2, you will learn the basics of programming – we will start with simple instructions, variables, and loops. You will write your first lines of code! To prepare, think about how you give instructions to a robot. What would you tell it to do? Bring your ideas to the next class.
Well done, young engineer! See you in Module 2! 👋
Hello again, future software engineer! In Module 1, you learned how to think like an engineer. Now it’s time to start building! Just like a builder uses bricks, cement, and wood, a software engineer uses variables, data types, and instructions to create programs.
In this module, we will learn the most basic parts of any programming language. We will not use a specific language (like Python or JavaScript) – instead, we will learn the ideas that work in every language. Once you understand these ideas, you can learn any coding language easily!
We will learn how to store information, how to name it, and how to give simple instructions. We will also learn how to make decisions using conditions. By the end, you will be able to write your first simple programs – on paper or on a computer. Let’s jump in!
After this module, you will be able to:
Ada’s mum gave her a shopping list: “Buy 2 loaves of bread, 5 apples, and 1 bottle of juice.” Ada went to the shop. She remembered “2”, “5”, and “1” – but when she reached the shop, she forgot what the 2 was for! Was it bread? Or apples?
So Ada took a notebook and wrote:
bread = 2 apples = 5 juice = 1
Now she knew exactly what each number meant. When she bought the items, she crossed them off. She even changed the numbers: bread = 1 (after buying one).
Her notebook acted like a computer’s memory. Each item name was a variable, and the number was its value. That is exactly how programs work – they store information in variables so they can use it later.
Now let’s learn how to do that with code!
Definition: A variable is a named container that holds a piece of information. It’s like a labelled box where you store something.
Why is it important? Without variables, a computer could not remember anything – it would forget everything after each step!
Simple explanation: Imagine a jar labelled “cookies”. You can put 10 cookies in it, or take some out. The jar always has a name, and the number of cookies inside can change. That’s a variable.
Real‑life example: Your school locker – you put books in it, and you can change what’s inside. The locker has a number (like Locker 42) – that’s the variable name, and the books are the value.
School example: Your test score – you might have a score of 85. Later, you get 90. The variable is “score”, and its value changes.
Home example: Your piggy bank – the variable is “piggyBank”, and the value is the amount of money inside.
Nigerian example: The number of people in a bus – the variable is “passengers”, and its value changes as people get on and off.
Illustration:
+-------------+ | name: age | ← variable name | value: 10 | ← variable value +-------------+
Mini summary: A variable is a labelled box that holds a piece of information that can change.
Definition: Data types tell the computer what kind of information a variable holds – like a number, a word, or a yes/no answer.
Why is it important? Because the computer needs to know how to handle the information. You can do math with numbers, but not with words.
Simple explanation: Think of three different boxes: one for numbers (like your age), one for words (like your name), and one for true/false (like “is it raining?”).
Real‑life example: A form asks for your name (text), age (number), and whether you are a student (true/false).
School example: Your teacher records your name (text), your test score (number), and if you did homework (true/false).
Home example: A recipe: 2 cups of flour (number), “sugar” (text), and “oven is hot?” (true/false).
Nigerian example: In a bank app: your account number (text), balance (number), and “is account active?” (true/false).
Illustration:
+----------------+------------------+------------------+ | Number | Text | True/False | | (integer) | (string) | (boolean) | +----------------+------------------+------------------+ | 10, 3.14, 0 | "Hello", "Ada" | true, false | +----------------+------------------+------------------+
Mini summary: Data types help the computer understand what kind of data it is working with – numbers, text, or true/false.
Definition: Naming variables means giving them clear, descriptive names so you and others know what they represent.
Why is it important? Good names make your code easy to read and understand – like having clear labels on boxes.
Simple explanation: If you name a variable “x”, nobody knows what it means. But if you name it “score”, everyone knows it holds a score.
Real‑life example: A teacher’s attendance sheet has columns like “Name”, “Absent”, “Tardy” – clear names.
School example: Your notebook headings: “Math Homework”, “Science Notes” – clear names.
Home example: Storage boxes labelled “Christmas Decorations” or “Winter Clothes”.
Nigerian example: A market trader labels baskets: “Tomatoes”, “Onions”, “Peppers” – not “Box1”, “Box2”.
Rules for naming:
first_name.totalScore is better than ts.Illustration:
✅ Good: playerName, age, isHungry ❌ Bad: p, a, 1var, my variable
Mini summary: Use clear, descriptive names for your variables – it helps everyone understand your code.
Definition: Assigning means putting a value into a variable. We use the assignment operator (usually =) to do this.
Why is it important? Because a variable is empty until you assign a value to it.
Simple explanation: It’s like saying “my piggy bank has 100 naira” – you are putting the value 100 into the variable “piggyBank”.
Real‑life example: You set your alarm clock to 7:00 – you are assigning the value 7 to the variable “alarmTime”.
School example: The teacher sets the score for your test: score = 85.
Home example: You tell your smart speaker the volume: volume = 5.
Nigerian example: You set your mobile data to “1GB” – that’s assigning a value.
Illustration:
age = 10 ← assignment ↑ ↑ name value
Mini summary: Assignment is putting a value into a variable using the equals sign.
Definition: Reading means using the value stored in a variable. You can use it in calculations, display it, or compare it.
Why is it important? Because storing data is useless if you can’t use it later!
Simple explanation: Like checking your piggy bank to see how much money you have – you read the value.
Real‑life example: Your phone displays your battery percentage – it reads the variable “batteryLevel”.
School example: Your teacher reads your name from the attendance list.
Home example: You check the temperature on your thermostat.
Nigerian example: A POS machine reads your account balance before a withdrawal.
Illustration:
age = 10 print(age) ← reads and displays the value (10)
Mini summary: Reading a variable means using its value.
Definition: Changing a variable means giving it a new value. The old value is replaced.
Why is it important? Because programs need to update information – like a game score that increases.
Simple explanation: You start with 10 cookies, you eat 2, now you have 8. The value changes.
Real‑life example: A football score starts at 0, then becomes 1, then 2 – the variable “score” changes.
School example: Your class attendance increases by 1 each day.
Home example: Your savings grow as you add money.
Nigerian example: The number of passengers on a bus changes at each stop.
Illustration:
score = 0 ← initial value score = 1 ← new value, old 0 is gone score = score + 1 ← adds 1 to current score (now 2)
Mini summary: You can change a variable by assigning a new value.
Definition: A statement is a single instruction that the computer executes – like a command.
Why is it important? Programs are made of many statements – they are the building blocks of code.
Simple explanation: It’s like saying “walk forward” – that’s one instruction.
Real‑life example: “Turn on the light” is a statement you give to your smart home.
School example: “Open your book” is a statement from the teacher.
Home example: “Set the timer for 10 minutes” is a statement.
Nigerian example: “Add 500 naira to my account” is a statement in a banking app.
Illustration:
// These are statements: age = 10 print(age) age = age + 1
Mini summary: A statement is one command that the computer performs.
Definition: A condition is a question that has a yes/no answer. Programs use conditions to decide what to do next.
Why is it important? Without conditions, programs would do the same thing every time – boring!
Simple explanation: “If it is raining, take an umbrella” – that’s a condition. If the answer is yes, you act; if no, you don’t.
Real‑life example: If your phone battery is below 20%, it shows a warning.
School example: If you score above 80, you get an A.
Home example: If the door is locked, you use a key.
Nigerian example: If the traffic light is red, you stop.
Illustration:
if (temperature > 30) {
wear_light_clothes()
} else {
wear_heavy_clothes()
}
Mini summary: Conditions let your program make choices based on true/false questions.
Definition: Comparison operators are symbols that compare two values and give a true/false answer. Examples: >, <, ==, !=, >=, <=.
Why is it important? They allow us to write conditions.
Simple explanation: You compare numbers: “Is 10 greater than 5?” Yes! “Is 10 equal to 5?” No!
Real‑life example: “Is your age >= 18?” Then you can vote.
School example: “Is your score > 70?” Then you pass.
Home example: “Is the fridge temperature > 4?” Then it’s too warm.
Nigerian example: “Is your bank balance > 1000?” Then you can withdraw.
Illustration:
5 == 5 → true 5 > 3 → true 5 < 3 → false 5 != 3 → true
Mini summary: Comparison operators ask questions and return true or false.
Definition: Logical operators combine two or more conditions. The main ones are AND, OR, and NOT.
Why is it important? Sometimes you need more than one condition to be true.
Simple explanation: “If it is raining AND I have an umbrella, I will go out.” Both must be true.
Real‑life example: A website asks: “If you are 18+ AND you agree to terms, you can sign up.”
School example: “If you did homework AND you studied, you will pass.”
Home example: “If the door is closed AND the window is locked, then the house is secure.”
Nigerian example: “If you have a valid ID AND you are on the list, you can vote.”
Illustration:
age >= 18 AND hasID == true → true only if both are true isWeekend OR isHoliday → true if either is true NOT isRaining → true if it is NOT raining
Mini summary: Logical operators combine conditions to form more complex questions.
Definition: Input is data that the program receives from the user, like a name or a number.
Why is it important? Programs become interactive – they respond to what you tell them.
Simple explanation: When a game asks “What is your name?” and you type it – that’s input.
Real‑life example: You type your username and password to log in.
School example: You answer a question on a quiz app.
Home example: You tell your smart speaker to set an alarm.
Nigerian example: You enter your phone number to recharge airtime.
Illustration:
name = input("What is your name?") ← user types "Ada"
print("Hello " + name)
Mini summary: Input allows the user to give data to the program.
Definition: Output is the information that the program gives back to the user – like displaying a result on the screen.
Why is it important? Without output, you wouldn’t know what the program did!
Simple explanation: When you add two numbers on a calculator and it shows the sum – that’s output.
Real‑life example: A weather app shows the temperature – that’s output.
School example: The computer displays your test score.
Home example: Your microwave beeps and shows “DONE”.
Nigerian example: A POS machine prints a receipt – that’s output.
Illustration:
print("Welcome to the game!")
print("Your score is " + score)
Mini summary: Output shows the user the results of the program.
Definition: You can combine variables to create new values. For example, adding numbers or joining text together.
Why is it important? This lets you build more complex information.
Simple explanation: If you have “first name” and “last name”, you can join them to get “full name”.
Real‑life example: In a game, your score is the sum of points from different levels.
School example: Your total grade is the average of all your test scores.
Home example: Your total savings = pocket money + gifts.
Nigerian example: Your monthly airtime = your recharge + bonus.
Illustration:
total = price + tax fullName = firstName + " " + lastName
Mini summary: You can use variables together to compute new values.
Definition: Pseudo‑code is a way to write algorithms that looks like code but is easy to read – it is not a real programming language.
Why is it important? It helps you plan your code before you write it in a specific language.
Simple explanation: It’s like writing a recipe in your own words – not in a special cooking language.
Real‑life example: A teacher writes the steps of a math problem on the board in plain English.
School example: You write the steps to solve a problem before actually solving it.
Home example: You write a to‑do list using simple words.
Nigerian example: A planner writes the steps for organising a community event.
Illustration:
// Pseudo-code to calculate grade
INPUT score
IF score >= 70 THEN
grade = "A"
ELSE
grade = "B"
END IF
PRINT grade
Mini summary: Pseudo‑code is a simple way to write algorithms without worrying about strict syntax.
Definition: Code is used in almost every electronic device – from phones to traffic lights.
Why is it important? It shows you that coding skills are useful in many areas.
Simple explanation: Every app, game, and website runs on code.
Real‑life example: Your calculator, your smartwatch, your TV remote – all contain code.
School example: The school portal, the lunch ordering system – all code.
Home example: Your Wi‑Fi router, your fridge with a screen – all code.
Nigerian example: The e‑Naira app, the NIN registration – all built with code.
Illustration:
+-------------------+ | Code is Everywhere | | Phones, Cars, Games, | | ATMs, Traffic Lights | +-------------------+
Mini summary: Code is everywhere – learning it opens many doors!
| Word | Simple Definition |
|---|---|
| Variable | A named box that holds a value. |
| Data Type | The kind of data: number, text, or true/false. |
| Assignment | Putting a value into a variable. |
| Statement | A single instruction in a program. |
| Condition | A question that is true or false. |
| Comparison Operator | Symbols like >, <, == to compare values. |
| Logical Operator | AND, OR, NOT to combine conditions. |
| Input | Data that the user gives to the program. |
| Output | Data that the program shows to the user. |
| Pseudo‑code | Plain‑language description of an algorithm. |
This module introduces the fundamental building blocks of programming. Focus on concepts over syntax. Use physical objects (like boxes or jars) to demonstrate variables. Encourage students to write pseudo‑code for everyday tasks. Emphasise that naming variables well is a sign of a good engineer.
Ask your child to identify variables in daily life – e.g., “What variables do we have when cooking?” (ingredients, quantities). Encourage them to think about conditions: “If it rains, what do we do?”. This strengthens their logic and prepares them for coding.
= instead of == in conditions – = is assignment, == is comparison.score not s.
Start
|
v
Is score >= 70?
/ \
Yes No
| |
v v
Pass Fail
| |
v v
End End
| Type | What it holds | Example |
|---|---|---|
| Integer | Whole numbers | 10, 0, -5 |
| Float | Decimal numbers | 3.14, 2.0 |
| String | Text | "Hello", "Ada" |
| Boolean | True or False | true, false |
| Operator | Meaning | Example |
|---|---|---|
| == | equal to | 5 == 5 → true |
| != | not equal to | 5 != 3 → true |
| > | greater than | 5 > 3 → true |
| < | less than | 5 < 3 → false |
| >= | greater than or equal | 5 >= 5 → true |
| <= | less than or equal | 5 <= 3 → false |
You have completed Module 2, and you now understand the core building blocks of all programming languages. You learned about variables – how to name them, assign values, and change them. You discovered different data types – numbers, text, and true/false. You also learned how to write statements, ask questions with conditions, and combine conditions with logical operators. Finally, you explored input and output, and you practiced writing pseudo‑code.
Remember: a program is just a series of instructions that manipulate variables. With these skills, you can start building simple programs – even games! You are now ready to learn a real programming language in Module 3.
= and ==? = is assignment, == is comparison.== operator do?= and ==?== is used for assignment. (False)age > 18 mean?!= mean?| Term | Definition |
|---|---|
| 1. Variable | A. A question that is true or false |
| 2. Data Type | B. A named container for data |
| 3. Condition | C. Kind of data: number, text, boolean |
| 4. Assignment | D. Putting a value into a variable |
| 5. Output | E. Data shown to the user |
Answers: 1‑B, 2‑C, 3‑A, 4‑D, 5‑E
Scenario 1: You are building a simple game. The player has 3 lives. Every time they lose, a life is removed. Write the pseudo‑code for this scenario.
Scenario 2: A school wants to check if a student has passed. If the score is 50 or above, they pass; otherwise, they fail. Write the pseudo‑code for this.
In groups, choose a simple task (e.g., making a sandwich, planning a school event). Write down the steps (algorithm) for that task. Then, swap with another group and see if they can follow your steps. Discuss any missing details. This shows how clear instructions are crucial in software.
Write a simple pseudo‑code program that asks the user for their name and age, then prints “Hello, [name]! You are [age] years old.”
Create a Simple Quiz: Write a pseudo‑code program that asks the user a question, checks if the answer is correct, and prints “Correct!” or “Try again!”. Use variables and conditions.
Write a pseudo‑code program that calculates the total cost of items in a shop. Use variables for price and quantity. The program should ask for the price and quantity, then display the total. Include a condition: if the total is above 1000, give a 10% discount.
Design a simple “Guess the Number” game using pseudo‑code. The program picks a secret number (e.g., 5). The user guesses a number. If the guess is correct, print “You win!”. If the guess is too high or too low, give a hint.
Fill‑in‑the‑Blank: 1. variable, 2. text/string, 3. comparison, 4. Input, 5. Output, 6. statement, 7. Pseudo‑code, 8. AND, 9. OR, 10. descriptive.
True/False: 1F, 2T, 3F, 4T, 5F, 6F, 7F, 8T, 9F, 10T.
Multiple Choice: 1B, 2A, 3B, 4B, 5B, 6B, 7A, 8B, 9B, 10A, 11A, 12B, 13A, 14B, 15D.
In Module 3, you will learn a real programming language! We will start with simple programs that use variables, conditions, and loops. You will also learn how to write code that actually runs on a computer. To prepare, think about what you would like to build – a game? A calculator? Bring your ideas to the next class!
Fantastic work, young coder! See you in Module 3! 🚀
Hello, superstar coder! In Module 2, you learned about variables, data types, and conditions. You can now store information and make decisions in your programs. But what if you need to repeat something many times? Or what if you have a whole list of items to work with?
Welcome to Module 3 – where we learn about loops (doing things again and again) and lists (holding many items together). We will also take our first steps into real code using a language called Python. Don’t worry – we will start slowly and explain everything.
By the end of this module, you will be able to write simple Python programs that use variables, conditions, loops, and lists. You will feel like a real programmer!
After this module, you will be able to:
while loop and a for loop (in pseudo‑code and Python).Chidi had to water 10 plants every morning. He walked to each plant, poured water, and moved to the next. That’s a lot of walking! He thought, “I wish I could tell someone to do this for me.”
His older brother, who was a software engineer, said: “Chidi, you can tell a computer to do it. Just say: repeat 10 times: water a plant.”
Chidi also had a list of plants: “Rose, Mango, Banana, Orange…” He kept the list on his phone. He could go through the list one by one.
That day, Chidi learned about loops (repeating) and lists (keeping items together). He realised that computers are great at doing boring, repetitive tasks quickly.
Now, let’s learn how to make computers do the same!
Definition: A loop is a programming structure that repeats a block of code multiple times.
Why is it important? Without loops, you would have to write the same code over and over – very boring and error‑prone!
Simple explanation: Think of a loop as telling your computer: “Do this thing, and keep doing it until I tell you to stop.”
Real‑life example: A washing machine runs a cycle – it repeats washing, rinsing, and spinning.
School example: Your teacher takes attendance every morning – that’s a daily loop.
Home example: You brush your teeth twice a day – that’s a loop.
Nigerian example: A traffic light cycles through red, yellow, green – that’s a loop.
Illustration:
+------------------+
| Start |
+--------+---------+
|
+--------v---------+
| Do something | <--+
+--------+---------+ |
| |
+--------v---------+ |
| Still need to | |
| repeat? | ---+ (if yes, go back)
+--------+---------+
|
+--------v---------+
| End |
+------------------+
Mini summary: A loop repeats a block of code as many times as needed.
Definition: A while loop repeats as long as a condition is true.
Why is it important? It allows you to repeat actions based on a condition – very flexible.
Simple explanation: “While my piggy bank is not full, I will add more money.”
Real‑life example: While the water is boiling, keep stirring.
School example: While there are still questions on the test, keep answering.
Home example: While the popcorn is popping, keep the lid on.
Nigerian example: While the bus is not full, the driver keeps waiting for more passengers.
Illustration:
count = 0
while count < 5:
print("Hello")
count = count + 1
// This prints "Hello" 5 times.
Mini summary: The while loop runs as long as the condition is true.
Definition: A for loop repeats a block of code for each item in a collection (like a list or a range of numbers).
Why is it important? It’s perfect when you know exactly how many times you want to repeat, or when you want to go through a list.
Simple explanation: “For each fruit in my basket, I will eat it.”
Real‑life example: A teacher calls each student’s name from the register – one by one.
School example: You check each question on a test paper.
Home example: You go through each item on your shopping list.
Nigerian example: A cashier scans each item in a customer’s basket.
Illustration:
for i in range(1, 6):
print(i)
// Prints: 1, 2, 3, 4, 5
Mini summary: The for loop runs for each item in a collection.
Definition: A list is a collection of items stored together in one variable. It can hold numbers, text, or even other lists!
Why is it important? Lists let you group related items so you can work with them easily.
Simple explanation: A list is like a bag of marbles – you can put many marbles in one bag, and you can take them out one by one.
Real‑life example: A shopping list – you have many items in one list.
School example: A class list of students.
Home example: A list of chores for the week.
Nigerian example: A list of markets in Lagos: “Balogun, Mile 12, Tejuosho”.
Illustration:
fruits = ["apple", "orange", "banana"] // fruits[0] is "apple" // fruits[1] is "orange" // fruits[2] is "banana"
Mini summary: A list stores multiple items in a single variable.
Definition: You can get an item from a list using its index (position). Indexing usually starts at 0.
Why is it important? You need to be able to read and change individual items in a list.
Simple explanation: If you have a list of 3 fruits, the first fruit is at position 0, the second at position 1, the third at position 2.
Real‑life example: In a queue, the first person is number 1 (but in programming we start at 0!).
School example: Your class list – the first student is at index 0.
Home example: The items on your shelf – first item at index 0.
Nigerian example: The list of players on a football team – the first player is index 0.
Illustration:
fruits = ["apple", "orange", "banana"] print(fruits[0]) // apple print(fruits[1]) // orange print(fruits[2]) // banana
Mini summary: Use square brackets and the index number to access list items.
Definition: You can change an item in a list by assigning a new value to its index.
Why is it important? Lists are dynamic – their contents can change while the program runs.
Simple explanation: If you have a list of the top 3 players, you can change who is number 1.
Real‑life example: You update your shopping list – crossing off items and adding new ones.
School example: You update the class attendance – marking students present or absent.
Home example: You change the chore list for the week.
Nigerian example: You update the list of items in your market stall.
Illustration:
fruits = ["apple", "orange", "banana"] fruits[1] = "grape" // now fruits = ["apple", "grape", "banana"]
Mini summary: You can change list items by assigning a new value to a specific index.
Definition: You can add new items to a list (e.g., with append()) or remove items.
Why is it important? Real‑world lists change – you need to be able to add and remove.
Simple explanation: Like adding a new fruit to your fruit bowl or taking one out.
Real‑life example: You add a new friend to your contact list.
School example: You add a new student to the class list.
Home example: You add an item to your shopping list.
Nigerian example: You add a new product to your online store’s catalogue.
Illustration:
fruits = ["apple", "orange"]
fruits.append("banana") // adds "banana" at the end
// fruits is now ["apple", "orange", "banana"]
Mini summary: Lists can grow and shrink – you can add and remove items.
Definition: You can use a for loop to go through every item in a list.
Why is it important? This is one of the most common tasks in programming – processing all items in a collection.
Simple explanation: “For each fruit in my fruit list, I will print its name.”
Real‑life example: A waiter reads each order from a list.
School example: The teacher calls each name from the class list.
Home example: You go through your shopping list and tick each item.
Nigerian example: A bus conductor reads each passenger’s destination from a list.
Illustration:
fruits = ["apple", "orange", "banana"]
for fruit in fruits:
print(fruit)
// Prints: apple, orange, banana (each on a new line)
Mini summary: Loops let you process every item in a list efficiently.
Definition: Python is a real programming language that is easy to read and write. We will now start writing actual Python code.
Why is it important? Python is used by millions of developers – it’s a great first language.
Simple explanation: Pseudo‑code is like a rough draft; Python is the final, running version.
Real‑life example: A chef writes a recipe (pseudo‑code) and then cooks the meal (Python).
School example: You plan an essay outline (pseudo‑code) and then write the full essay (Python).
Home example: You plan a party (pseudo‑code) and then execute the plan (Python).
Nigerian example: An architect designs a building (pseudo‑code) and then workers build it (Python).
Illustration:
// Pseudo-code:
score = 70
if score >= 70:
print("Pass")
else:
print("Fail")
// Python code (exactly the same!):
score = 70
if score >= 70:
print("Pass")
else:
print("Fail")
Mini summary: Python code looks very similar to pseudo‑code – it’s easy to learn!
Definition: A Python program is a file containing Python code. You can run it to see the output.
Why is it important? This is where you bring all your learning to life!
Simple explanation: You type code in a file, save it, and run it – the computer follows your instructions.
Real‑life example: You write a recipe, follow it, and enjoy the meal.
School example: You write a story, read it aloud, and others hear it.
Home example: You write a shopping list, go to the shop, and buy the items.
Nigerian example: You write a list of errands, go out, and complete them.
Illustration:
# This is a Python program
name = "Chidi"
age = 10
print("Hello, my name is", name)
print("I am", age, "years old.")
Mini summary: A Python program is a file with code that you can run.
Definition: Python uses if, elif, and else to make decisions, just like pseudo‑code.
Why is it important? This is how you add logic to your programs.
Simple explanation: “If it rains, take an umbrella; else, take sunglasses.”
Real‑life example: If your phone battery is low, charge it; else, keep using it.
School example: If you score above 80, you get an A; else, you get a B.
Home example: If the door is open, go inside; else, use the key.
Nigerian example: If the bus is full, wait for the next one; else, board.
Illustration:
score = 85
if score >= 70:
print("Pass")
elif score >= 50:
print("Remedial")
else:
print("Fail")
Mini summary: Python conditions work just like the ones you learned in pseudo‑code.
Definition: The while loop in Python repeats as long as a condition is true.
Why is it important? It gives you flexible repetition.
Simple explanation: “While I have money, I will keep buying.”
Real‑life example: While the traffic light is red, you wait.
School example: While the teacher is talking, you listen.
Home example: While the popcorn is popping, you wait.
Nigerian example: While the okada (motorcycle) is moving, you hold tight.
Illustration:
count = 0
while count < 5:
print("Looping!")
count = count + 1
Mini summary: Python's while loop works the same as in pseudo‑code.
Definition: The for loop in Python iterates over a sequence (like a list or range).
Why is it important? It’s the most common way to iterate in Python.
Simple explanation: “For each player on the team, print their name.”
Real‑life example: For each item in your shopping list, buy it.
School example: For each student in the class, mark attendance.
Home example: For each chore on the list, do it.
Nigerian example: For each market in the list, visit it.
Illustration:
fruits = ["apple", "orange", "banana"]
for fruit in fruits:
print("I like", fruit)
Mini summary: Python's for loop makes it easy to go through lists.
Definition: You can use loops to process every item in a list – this is very powerful.
Why is it important? It allows you to perform operations on all items in a collection.
Simple explanation: You have a list of numbers, and you want to add 1 to each number.
Real‑life example: A teacher adds 10 points to each student’s score.
School example: You check each answer in a test.
Home example: You update the quantity of each item on your shopping list.
Nigerian example: A trader updates the price of each item in her store.
Illustration:
numbers = [1, 2, 3, 4, 5]
for i in range(len(numbers)):
numbers[i] = numbers[i] + 1
// numbers is now [2, 3, 4, 5, 6]
Mini summary: Loops and lists work together to process collections of data.
Definition: A real Python program combines variables, conditions, loops, and lists to solve a problem.
Why is it important? This is what software engineers do every day – writing programs that solve problems.
Simple explanation: You write a program that helps you organise your tasks.
Real‑life example: A to‑do list app that lets you add, remove, and view tasks.
School example: A program that calculates your average grade.
Home example: A program that helps you plan your weekly meals.
Nigerian example: A program that calculates the total cost of items in a market basket.
Illustration:
# Program to calculate the average of numbers in a list
numbers = [10, 20, 30, 40, 50]
total = 0
for num in numbers:
total = total + num
average = total / len(numbers)
print("Average is", average)
Mini summary: Real programs combine all the elements you have learned to solve useful problems.
| Word | Simple Definition |
|---|---|
| Loop | Repeating a block of code multiple times. |
| While Loop | A loop that repeats while a condition is true. |
| For Loop | A loop that repeats for each item in a collection. |
| List | A collection of items stored together. |
| Index | The position of an item in a list (starting at 0). |
| Append | Adding an item to the end of a list. |
| Python | A real programming language that is easy to learn. |
| A Python function that displays output. | |
| Range | A function that generates a sequence of numbers. |
| Iterate | To go through each item in a collection. |
while.count < 5).:.count = count + 1) to avoid infinite loops.for.fruit).in and the list name (e.g., fruits).:.This module is a transition from pseudo‑code to real Python. Focus on the similarities – Python code looks almost exactly like pseudo‑code. Emphasise indentation and the importance of avoiding infinite loops. Use interactive exercises where students can run Python code (even mentally). Celebrate each small success.
Encourage your child to write small Python programs on paper. Help them set up a Python environment on a computer if possible. Ask them to explain what a loop is and how it works. Relate loops to daily routines – “What do you repeat every morning?”
for loop in Python can also loop through strings, not just lists?while loop.= instead of == in conditions – assignment vs comparison.
Start
|
v
Condition true? → No → End
|
Yes
|
v
Execute block
|
v
(go back to condition)
| Feature | While Loop | For Loop |
|---|---|---|
| Condition | Checked each time | Built-in for each item |
| Best for | When you don't know how many times | When you know the count or have a list |
| Risk | Infinite loop if condition never false | Less risk, because it stops after the list ends |
| Operation | Example | Result |
|---|---|---|
| Access | fruits[0] | First fruit |
| Change | fruits[1] = "grape" | Second fruit becomes "grape" |
| Add (append) | fruits.append("mango") | Adds "mango" at the end |
| Length | len(fruits) | Number of items in the list |
You have completed Module 3 – a huge milestone! You learned about loops (while and for) that let you repeat code. You discovered lists – powerful containers that hold multiple items. Most importantly, you started writing real Python code that runs on a computer. You now understand the core elements of programming: variables, data types, conditions, loops, and lists.
You can now write simple programs that can solve real problems. Remember, programming is a skill – the more you practice, the better you become. In Module 4, we will go deeper into functions and more advanced Python features.
You are now an official Python beginner – well done!
while repeats based on a condition, for repeats for each item in a collection.append() method.range() in Python? It generates a sequence of numbers for loops.while loop do?for loop do?while and for?len() do?for loop can only be used with lists. (False – it can also be used with strings, ranges, etc.)append() removes an item from a list. (False – it adds.)while loop always runs at least once. (False – it checks the condition first.)forwhiledorepeatadd()append()insert()push()print() do in Python?for loop in Python?for i in range(5):for i to 5:for i=1 to 5:for i in 5:len() do?items?items[1]items[2]items[0]items.get(1)for loop?range(1, 6) function generate?| Term | Definition |
|---|---|
| 1. Loop | A. A collection of items |
| 2. List | B. Repeating code |
| 3. Index | C. Position of an item in a list |
| 4. Append | D. Add an item to a list |
| 5. Python | E. A real programming language |
Answers: 1‑B, 2‑A, 3‑C, 4‑D, 5‑E
while loop and a for loop.names?range() in a for loop?Scenario 1: You are writing a program to calculate the total price of items in a shopping cart. The cart is a list of prices (e.g., [100, 50, 200]). Write the Python code to sum all the prices and print the total.
Scenario 2: You have a list of student scores. You want to give a bonus of 5 points to each student. Write the Python code to update the list with the bonus.
In groups, come up with a simple problem that can be solved with a loop and a list. For example, “List of 5 favourite foods” – write a Python program to print each food with a number. Each group presents their program.
Write a Python program that asks the user for 5 numbers, stores them in a list, and then prints the sum of all numbers. Use a loop to ask for the numbers.
while loop instead of a for loop?Build a To‑Do List Program: Write a Python program that allows the user to add tasks, view the list, and mark tasks as done. Use a list to store tasks. Include a loop to keep the program running until the user chooses to exit.
Write a Python program that takes a list of numbers and prints the largest and the smallest numbers. Test it with the list: [45, 78, 12, 90, 34].
Write a Python program that generates a list of 10 random numbers (between 1 and 100) and then counts how many are even and how many are odd. (Hint: use a loop and the modulo operator %).
Fill‑in‑the‑Blank: 1. loop, 2. while, 3. for, 4. list, 5. index, 6. append, 7. Python, 8. indentation, 9. print, 10. infinite.
True/False: 1F, 2T, 3F, 4F, 5T, 6T, 7F, 8F, 9F, 10T.
Multiple Choice: 1A, 2B, 3B, 4B, 5B, 6B, 7B, 8A, 9C, 10B, 11A, 12A, 13B, 14A, 15D.
In Module 4, you will learn about functions – a way to group code into reusable blocks. You will also learn about more advanced data structures. To prepare, think about tasks you repeat often – those are perfect candidates for functions. Bring your ideas to the next class!
Amazing work, Python coder! See you in Module 4! 🐍
Hello, brilliant builder! In Module 3, you learned how to use loops and lists to make your programs more powerful. You even wrote your first real Python programs. Now, it is time to learn how to organise your code so it stays neat, reusable, and easy to understand.
Have you ever built something with Lego? You use the same blocks to build many different things. In programming, functions are like Lego blocks – you write a piece of code once, and then you can use it again and again!
We will also learn about modules – which are like boxes full of useful tools that other people have already built. And we will learn how to write clean code – code that is easy to read and understand, even for beginners.
By the end of this module, you will be able to write programs that are organised, reusable, and professional. Let’s get started!
After this module, you will be able to:
Aisha loved making smoothies. She had a big recipe book with many smoothie recipes. Every time a customer ordered, she would find the recipe and make it from scratch. But she noticed that many steps were the same – peel, chop, blend, pour.
One day, she had an idea. She wrote down the common steps as a recipe template (like a function). For each smoothie, she would just write the ingredients (the parameters) and the template would do the rest.
She also kept a box of tools – a blender, a knife, a juicer – that she could use anytime. These were like modules – ready‑to‑use tools.
Aisha could now serve customers much faster, and her recipes were easy to change. She had become a master organiser – just like a software engineer!
Now, let’s learn how to write our own recipe templates – functions!
Definition: A function is a block of reusable code that performs a specific task. You can call (use) it whenever you need it.
Why is it important? Functions help you avoid repeating code. Write once, use many times!
Simple explanation: Think of a function like a recipe in a cookbook. The recipe has a name, a list of ingredients, and a set of instructions. Once you have the recipe, you can make the dish any time.
Real‑life example: A washing machine has a “wash” function – you put clothes in, and it does the washing.
School example: Your teacher uses a “mark_attendance” function – she calls it every day.
Home example: You have a “make_tea” function – you follow the same steps each time.
Nigerian example: A bank has a “transfer_money” function – it is used whenever a customer transfers funds.
Illustration:
+------------------+
| Function |
| "greet" |
+--------+---------+
|
+--------v---------+
| Input: name |
+--------+---------+
|
+--------v---------+
| print("Hello, |
| " + name)|
+--------+---------+
|
+--------v---------+
| Output: Hello, |
| [name] |
+------------------+
Mini summary: A function is a reusable block of code that does a specific job.
Definition: Defining a function means creating it – giving it a name and writing the instructions it will perform.
Why is it important? You must define a function before you can use it.
Simple explanation: Like writing a new recipe in your cookbook – you write the instructions, then you can follow them later.
Real‑life example: You write a to‑do list – each task is like a function definition.
School example: Your teacher writes the lesson plan – it’s a plan to be followed.
Home example: You write a shopping list – it defines what you need to buy.
Nigerian example: A farmer writes a planting schedule – it defines when to plant each crop.
Illustration:
def greet():
print("Hello!")
# This defines a function called "greet".
# When we call it, it will print "Hello!".
Mini summary: You define a function using the def keyword, followed by the name and parentheses.
Definition: Calling a function means running (executing) the code inside it.
Why is it important? A function does nothing until you call it – you have to tell it to work!
Simple explanation: You have a recipe for a cake. Calling the function is like actually baking the cake.
Real‑life example: You press the “on” button on your TV – that calls the “turn_on” function.
School example: The teacher says “take attendance” – that calls the attendance function.
Home example: You ask your smart speaker to “play music” – that calls a function.
Nigerian example: You use a POS machine to “withdraw cash” – that calls a function.
Illustration:
# Define the function
def greet():
print("Hello!")
# Call the function
greet() # This prints "Hello!"
Mini summary: You call a function by writing its name followed by parentheses.
Definition: Parameters are variables that you pass to a function – they are like ingredients for the recipe.
Why is it important? Parameters make functions flexible – they can work with different data.
Simple explanation: A recipe for a smoothie needs ingredients like fruit and milk. The fruit is a parameter – you can change it to make different smoothies.
Real‑life example: A vending machine – you insert money (a parameter) and get a snack.
School example: The attendance function takes a “student name” as a parameter.
Home example: The “set_alarm” function takes a “time” parameter.
Nigerian example: A mobile banking function “transfer” takes “amount” and “recipient” as parameters.
Illustration:
def greet(name):
print("Hello, " + name)
greet("Aisha") # Prints: Hello, Aisha
greet("Chidi") # Prints: Hello, Chidi
Mini summary: Parameters are variables that you pass into a function to customise its behaviour.
Definition: A return value is the output that a function sends back after it finishes.
Why is it important? Functions often compute something – the return value is the result you can use.
Simple explanation: You give money to a shopkeeper (input), they give you change (return value).
Real‑life example: A calculator – you input numbers, it returns the sum.
School example: You answer a test – the teacher returns a score.
Home example: A thermometer – it returns the temperature.
Nigerian example: A bank function “check_balance” returns the account balance.
Illustration:
def add(a, b):
result = a + b
return result
sum = add(5, 3)
print(sum) # Prints 8
Mini summary: The return statement sends a value back from the function.
Definition: Functions make your code modular – you can build your program from small, independent pieces.
Why is it important? They save you time, reduce errors, and make your code easier to read.
Simple explanation: Instead of repeating the same code, you write a function once and use it many times.
Real‑life example: A chef uses the same knife‑cutting technique for many dishes – that’s a function.
School example: You use the same study method for different subjects.
Home example: You use the same cleaning routine for each room.
Nigerian example: A driver uses the same “start_engine” function for different cars.
Illustration:
# Without a function (repeated code)
print("Good morning!")
print("Good morning!")
print("Good morning!")
# With a function (reusable)
def greet():
print("Good morning!")
greet()
greet()
greet()
Mini summary: Functions save time and reduce repetition – they are a key tool for any programmer.
Definition: Scope means where a variable can be accessed – inside a function, it’s local; outside, it’s global.
Why is it important? It helps you keep your code organised and prevents conflicts.
Simple explanation: A variable inside a function is like a secret – only that function can see it.
Real‑life example: Your phone’s password is known only to you (local), not to everyone (global).
School example: Your test answers are only in your test paper (local), not in everyone’s.
Home example: Your room is your space – only you know where your things are.
Nigerian example: A market trader’s pricing strategy is local – not everyone knows it.
Illustration:
x = 10 # global variable
def my_function():
y = 5 # local variable
print(x) # can access global x
print(y) # can access local y
# print(y) # ERROR! y is not defined outside
Mini summary: Variables defined inside a function are local; variables defined outside are global.
Definition: A module is a file containing Python code – usually functions and variables – that you can import and use.
Why is it important? Modules let you use code that others have written – you don’t have to reinvent the wheel.
Simple explanation: A module is like a toolbox. You open it, pick a tool, and use it.
Real‑life example: A carpenter has a toolbox with a hammer, saw, and screws – all ready to use.
School example: A teacher has a resource book with ready‑made exercises.
Home example: A kitchen has a spice rack – you use different spices for different dishes.
Nigerian example: A mechanic has a set of tools – each tool is like a module.
Illustration:
import math # import the math module
print(math.sqrt(16)) # 4.0 (square root)
print(math.pi) # 3.14159...
Mini summary: Modules are pre‑written code that you can import to add new capabilities.
Definition: Importing means bringing a module into your program so you can use its functions and variables.
Why is it important? It gives you access to a huge library of code.
Simple explanation: Like borrowing a book from the library – you bring it to your desk to read.
Real‑life example: You import a video player to watch a movie.
School example: Your teacher uses a textbook from the library.
Home example: You use a recipe from a cookbook.
Nigerian example: A trader imports goods to sell in the market.
Illustration:
import random # module for random numbers
print(random.randint(1, 10)) # prints a random number between 1 and 10
Mini summary: You import modules using the import keyword.
Definition: You can create your own module by saving a Python file and then importing it into another program.
Why is it important? It allows you to reuse your code across many projects.
Simple explanation: You write a list of useful functions in a file, and you can use them in any program.
Real‑life example: You write a collection of recipes in a notebook – it becomes your own cookbook.
School example: You make a study guide – you can use it for different exams.
Home example: You make a list of chore routines – you can follow them every week.
Nigerian example: A tailor creates a pattern for a dress – they can use it for many dresses.
Illustration:
# Save this as my_tools.py
def greet(name):
print("Hello, " + name)
# In another file:
import my_tools
my_tools.greet("Aisha") # Hello, Aisha
Mini summary: You can create your own modules by saving Python code in a file and importing it.
Definition: Clean code is code that is easy to read, understand, and modify.
Why is it important? Clean code saves time and reduces bugs – it’s like a tidy room.
Simple explanation: Clean code is like a well‑written story – clear sentences, good spacing, and understandable words.
Real‑life example: A well‑organised book – each chapter has a title and clear sections.
School example: Your notebook with neat handwriting and headings.
Home example: A tidy kitchen where everything is in its place.
Nigerian example: A well‑organised market – each section is clearly labelled.
Illustration:
# Clean code example
def calculate_average(scores):
"""This function calculates the average of a list of scores."""
total = sum(scores)
count = len(scores)
average = total / count
return average
Mini summary: Clean code is easy to read, has good variable names, and has comments to explain.
Definition: Comments are notes in the code that are ignored by the computer – they are for human readers.
Why is it important? They explain what the code does – helpful for yourself and others.
Simple explanation: Like writing margin notes in a book to remember important points.
Real‑life example: A recipe with notes: “Add salt to taste”.
School example: Your notes on a textbook – highlighting key sentences.
Home example: A sticky note on the fridge: “Buy milk”.
Nigerian example: A signpost in the market: “Shoe section”.
Illustration:
# This is a comment
# It explains that the next line prints a greeting
print("Hello!")
Mini summary: Comments start with # and are ignored by Python – they are for programmers.
Definition: Naming conventions are guidelines for naming variables, functions, and modules to make code more readable.
Why is it important? Good names make your code self‑explanatory – you don’t need extra comments.
Simple explanation: Use names that describe what the variable or function does.
Real‑life example: A street is named “Market Road” – you know where it leads.
School example: A book titled “Mathematics for Beginners” – you know what it’s about.
Home example: A drawer labelled “Cutlery” – you know what’s inside.
Nigerian example: A bus named “Eko” – you know it goes to Lagos.
Illustration:
# Good names
user_age = 10
def calculate_score():
...
# Bad names
a = 10
def cs():
...
Mini summary: Use descriptive, clear names – it makes your code easier to understand.
Definition: Refactoring is the process of improving the design of existing code without changing its behaviour.
Why is it important? It makes code cleaner, faster, and easier to maintain.
Simple explanation: Like cleaning your room – you rearrange things to make them more organised.
Real‑life example: A chef reorganises the kitchen to work faster.
School example: You rewrite your notes to make them clearer.
Home example: You redecorate your room for better use of space.
Nigerian example: A shop owner rearranges the shop to make it easier for customers.
Illustration:
# Before refactoring (repeated code)
total = 0
for i in range(5):
total = total + i
print(total)
# After refactoring (using a function)
def sum_range(n):
total = 0
for i in range(n):
total = total + i
return total
print(sum_range(5))
Mini summary: Refactoring is improving your code’s structure without changing what it does.
Definition: Reusability means using the same code (like a function or module) in multiple places.
Why is it important? It saves time, reduces errors, and makes programs easier to maintain.
Simple explanation: Like using the same recipe to bake many cakes.
Real‑life example: A template for a letter – you fill in the name and address.
School example: You use the same study technique for different subjects.
Home example: You use the same chore list every week.
Nigerian example: A tailor uses the same pattern for many different fabrics.
Illustration:
# Reusable function
def welcome(name):
print("Welcome, " + name + "!")
welcome("Aisha")
welcome("Chidi")
welcome("Ada")
Mini summary: Reusability is a core principle of software engineering – write once, use many times.
| Word | Simple Definition |
|---|---|
| Function | A reusable block of code that does a specific task. |
| Parameter | An input that you pass to a function. |
| Return Value | The output that a function sends back. |
| Module | A file containing Python code that you can import. |
| Import | To bring a module into your program. |
| Scope | Where a variable is accessible – local or global. |
| Clean Code | Code that is easy to read and understand. |
| Comment | A note in the code that is ignored by the computer. |
| Refactoring | Improving code without changing what it does. |
| Reusability | Using the same code in multiple places. |
def keyword, followed by the function name and parentheses.: and indent the function body.import module_name at the top of your file.module_name.function_name().from module_name import function_name to import a specific function.This module is about organisation and reuse. Encourage students to identify repeated patterns in their code and turn them into functions. Use physical analogies (Lego blocks, recipes) to explain functions. Emphasise the importance of writing clean, readable code from the beginning.
Ask your child to think about routines they repeat daily (like brushing teeth) – that’s a function! Discuss how they could “write a recipe” for that routine. Encourage them to keep their code clean and organised, just like keeping their room tidy.
as? (e.g., import math as m)def, you call by name.calculate_average instead of ca.
+------------------+
| Start |
+--------+---------+
|
+--------v---------+
| Call function |
+--------+---------+
|
+--------v---------+
| Execute code |
+--------+---------+
|
+--------v---------+
| Return result |
+--------+---------+
|
+--------v---------+
| Continue |
+------------------+
| Feature | Function | Module |
|---|---|---|
| Definition | A reusable block of code | A file containing code |
| Scope | Inside a program | Can be used across programs |
| Example | def greet(): | import math |
| Reusability | Within one program | Across many programs |
def add(a, b):
"""This function adds two numbers and returns the result."""
return a + b
You have completed Module 4 – a huge step towards becoming an advanced software engineer! You learned about functions – the building blocks of reusable code. You now know how to define functions, pass parameters, and return values. You also learned about modules – ready‑made tools that you can import and use. You discovered the importance of clean code, comments, and good naming conventions.
With these skills, you can write programs that are organised, easy to understand, and easy to improve. You are now ready to build larger, more complex applications.
Keep practising – every great engineer started where you are now!
import keyword – e.g., import math.function name():def name():define name():func name():include mathimport mathuse mathrequire mathfunctiondefdefinefunc| Term | Definition |
|---|---|
| 1. Function | A. A reusable block of code |
| 2. Parameter | B. An input to a function |
| 3. Return | C. The output from a function |
| 4. Module | D. A file containing Python code |
| 5. Comment | E. A note in the code |
Answers: 1‑A, 2‑B, 3‑C, 4‑D, 5‑E
Scenario 1: You are building a simple calculator. Write a function for addition, subtraction, multiplication, and division. Each function takes two numbers as parameters and returns the result.
Scenario 2: You have a list of student names. Write a function that takes a list and a name, and returns True if the name is in the list, False otherwise.
In groups, write a program that uses a function to calculate the average of a list of numbers. Then, write another function that uses the first function to calculate the average of multiple groups. Present your code and explain how you used functions to keep the code organised.
Write a Python program that includes a function called is_even that takes a number and returns True if it is even, False otherwise. Then, use a loop to ask the user for numbers and print whether each is even or odd.
Build a Text‑Based Adventure Game: Write a Python program that uses functions to handle different parts of the game – e.g., start_game(), show_instructions(), play_round(). Use parameters and return values to pass data between functions.
Write a Python program that uses the math module to calculate the square root, sine, and cosine of a number entered by the user. Use functions to organise your code.
Write a Python program that defines a function fibonacci(n) that returns the nth Fibonacci number (the first two are 1, 1, then each is the sum of the previous two). Test it with different values.
Fill‑in‑the‑Blank: 1. function, 2. def, 3. Parameters, 4. return, 5. module, 6. import, 7. Clean, 8. Comments, 9. Refactoring, 10. Don’t Repeat Yourself.
True/False: 1F, 2T, 3T, 4F, 5T, 6F, 7F, 8F, 9T, 10T.
Multiple Choice: 1B, 2B, 3B, 4B, 5B, 6B, 7B, 8B, 9B, 10B, 11B, 12B, 13B, 14B, 15C.
In Module 5, you will learn about objects and classes – a more advanced way to organise code. You will also explore file handling, so your programs can save data and read it back. To prepare, think about real‑world objects (like a car or a phone) and how they have properties (color, speed) and actions (start, stop).
You are becoming a true engineer – keep going! See you in Module 5!
Hello, amazing coder! You have learned so much already – variables, loops, lists, functions, and modules. Now, we are going to enter the world of objects and classes. This is how big programs are built in the real world!
Think about your favorite video game. It has characters, weapons, and levels. Each character has a name, health, and abilities. In programming, we can create a class as a blueprint for a character. Then we make many objects from that blueprint – each with their own name and health.
We will also learn how to save data to files – so your programs can remember things even after you turn off the computer!
By the end of this module, you will be able to create your own objects and save data to files. You will feel like a real software engineer building complex systems. Let’s go!
After this module, you will be able to:
Kofi loved football. He wanted to create a computer program to manage his team. He had players with names, jersey numbers, and positions. He thought, “I need a way to represent a player in my program.”
His older sister, a software engineer, explained: “You can create a class called ‘Player’. The class is like a form – it has fields for name, jersey, and position. Then you can create many objects – one for each player – by filling in the form.”
Kofi also wanted to save the team data so he could load it later. His sister showed him how to save to a file – like writing the team list in a notebook.
Now Kofi could create any number of players, save the team, and load it back – just like a real football manager!
Let’s learn how to do the same in Python!
Definition: An object is a thing that has properties (data) and actions (functions). It represents something from the real world.
Why is it important? Objects help us model real‑world things in code – like a car, a person, or a bank account.
Simple explanation: Think of a toy car. It has a color, a size, and it can move forward and backward. That’s an object!
Real‑life example: Your phone is an object – it has a brand, a screen size, and it can call and text.
School example: A student is an object – they have a name, a class, and they can study.
Home example: A chair is an object – it has a color, material, and you can sit on it.
Nigerian example: A bus (danfo) is an object – it has a color, a number of seats, and it can transport passengers.
Illustration:
+-----------------+
| Car Object |
+-----------------+
| Properties: |
| - each dress made is an object.
Illustration:
+---------------------------+
| Class: Player |
+---------------------------+
| Properties: |
| - name |
| - jersey_number |
| - position |
+---------------------------+
| Actions: |
| - score_goal() |
| - pass_ball() |
+---------------------------+
|
v
+---------------------------+
| Object 1: "Kofi" |
| jersey: 10, forward |
+---------------------------+
| Object 2: "Ama" |
| jersey: 5, defender |
+---------------------------+
Mini summary: A class is a blueprint; an object is a specific example made from that blueprint.
📘 Lesson 3: Defining a Class in Python
Definition: In Python, you define a class using the class keyword, followed by the class name.
Why is it important? This is how you create your own blueprint for objects.
Simple explanation: You write class Player: and then indent the properties and actions.
Real‑life example: You write the blueprint for a house – rooms, doors, windows.
School example: The school has a class called “Student” – every student is an object.
Home example: You define a class “Book” – each book has a title and author.
Nigerian example: A bank defines a class “Customer” – each customer is an object.
Illustration:
class Player:
def __init__(self, name, jersey):
self.name = name
self.jersey = jersey
def display(self):
print("Player: " + self.name + ", Jersey: " + str(self.jersey))
Mini summary: Use class to define a blueprint. The __init__ method sets up the object.
📘 Lesson 4: Creating Objects (Instances)
Definition: Creating an object from a class is called instantiation. You use the class name like a function.
Why is it important? This is how you actually create usable objects in your program.
Simple explanation: You take the cookie cutter and press it into the dough – that makes a cookie (object).
Real‑life example: You use the car blueprint to build a specific car – that’s creating an object.
School example: The school registers a new student – that creates a student object.
Home example: You bake a cake using the recipe – that creates a cake object.
Nigerian example: A bank opens a new account – that creates a customer object.
Illustration:
player1 = Player("Kofi", 10)
player2 = Player("Ama", 5)
player1.display() # Player: Kofi, Jersey: 10
player2.display() # Player: Ama, Jersey: 5
Mini summary: You create objects by calling the class name with the required data.
📘 Lesson 5: Attributes – The Data of an Object
Definition: Attributes are the variables that belong to an object. They hold the object’s data.
Why is it important? Attributes store the state of an object – like a player’s name and jersey.
Simple explanation: A car has attributes like color, model, and speed.
Real‑life example: A phone has attributes – brand, screen size, battery life.
School example: A student has attributes – name, age, class.
Home example: A pet has attributes – name, breed, age.
Nigerian example: A bank account has attributes – account number, balance, owner name.
Illustration:
class Dog:
def __init__(self, name, breed):
self.name = name # attribute
self.breed = breed # attribute
dog1 = Dog("Bingo", "German Shepherd")
print(dog1.name) # Bingo
print(dog1.breed) # German Shepherd
Mini summary: Attributes are the data that each object stores.
📘 Lesson 6: Methods – The Actions of an Object
Definition: Methods are functions that belong to an object. They define what the object can do.
Why is it important? Methods allow objects to perform actions – like a player scoring a goal.
Simple explanation: A car has methods – accelerate, brake, turn.
Real‑life example: A phone has methods – call, send_text, take_photo.
School example: A student has methods – study, take_exam.
Home example: A remote control has methods – turn_on, turn_off, change_channel.
Nigerian example: A bank account has methods – deposit, withdraw, check_balance.
Illustration:
class Player:
def __init__(self, name, goals):
self.name = name
self.goals = goals
def score(self):
self.goals = self.goals + 1
print(self.name + " scored! Total: " + str(self.goals))
kofi = Player("Kofi", 0)
kofi.score() # Kofi scored! Total: 1
kofi.score() # Kofi scored! Total: 2
Mini summary: Methods are actions that objects can perform.
📘 Lesson 7: The __init__ Method – The Constructor
Definition: __init__ is a special method that runs automatically when you create a new object. It initialises (sets up) the object’s attributes.
Why is it important? It ensures every object starts with the correct data.
Simple explanation: It’s like filling out a form when you register – you provide your name and other details.
Real‑life example: When you buy a phone, it comes with a charger and manual – that’s initialisation.
School example: When a new student joins, they fill out a registration form – that’s __init__.
Home example: When you get a new pet, you give it a name and register it at the vet.
Nigerian example: Opening a bank account – you provide your name, address, and ID.
Illustration:
class Car:
def __init__(self, make, model):
self.make = make
self.model = model
self.speed = 0 # default value
car1 = Car("Toyota", "Camry")
print(car1.make) # Toyota
print(car1.speed) # 0
Mini summary: __init__ is the setup method that runs when you create an object.
📘 Lesson 8: Inheritance – Reusing Code with Parent Classes
Definition: Inheritance allows a new class to borrow (inherit) attributes and methods from an existing class.
Why is it important? It promotes reusability – you don’t have to write everything from scratch.
Simple explanation: A “Car” class is a parent. A “ElectricCar” class can inherit from Car – it gets all the car features, plus extra ones.
Real‑life example: All phones have a screen and battery. A “Smartphone” inherits from “Phone” and adds apps.
School example: A “Student” is a person. “Teacher” is also a person – they both inherit from “Person”.
Home example: A “Dog” and a “Cat” both inherit from “Pet”.
Nigerian example: A “Account” class – “SavingsAccount” and “CurrentAccount” inherit from it.
Illustration:
class Pet:
def __init__(self, name):
self.name = name
def eat(self):
print(self.name + " is eating.")
class Dog(Pet):
def bark(self):
print(self.name + " says woof!")
dog1 = Dog("Bingo")
dog1.eat() # Bingo is eating. (inherited)
dog1.bark() # Bingo says woof! (own method)
Mini summary: Inheritance lets a child class reuse code from a parent class.
📘 Lesson 9: Why Use Objects and Classes?
Definition: Objects and classes help you organise code in a way that mirrors the real world.
Why is it important? They make large programs easier to manage and understand.
Simple explanation: Instead of having many separate variables, you group related data and actions into objects.
Real‑life example: A game with many characters – each is an object with health, position, and abilities.
School example: A school management system – students, teachers, classes are all objects.
Home example: A smart home system – lights, thermostats, and doors are objects.
Nigerian example: A banking app – customers, accounts, and transactions are objects.
Illustration:
+-----------------------+
| Without Objects |
+-----------------------+
| player1_name = "Kofi" |
| player1_goals = 0 |
| player2_name = "Ama" |
| player2_goals = 0 |
+-----------------------+
+-----------------------+
| With Objects |
+-----------------------+
| player1 = Player("Kofi", 0) |
| player2 = Player("Ama", 0) |
+-----------------------+
Mini summary: Objects help organise code by grouping related data and actions.
📘 Lesson 10: Reading from a File
Definition: Reading from a file means getting data that is stored on your computer’s hard drive.
Why is it important? Files store data permanently – even after you turn off the computer.
Simple explanation: Like reading a book – you open it and read the words.
Real‑life example: A game loads your saved progress from a file.
School example: Your teacher opens a file to view your grades.
Home example: You open a recipe file to read the instructions.
Nigerian example: A bank opens a file to load customer data.
Illustration:
file = open("data.txt", "r")
content = file.read()
print(content)
file.close()
Mini summary: Use open() with "r" to read from a file.
📘 Lesson 11: Writing to a File
Definition: Writing to a file means saving data from your program to a file on the computer.
Why is it important? You can save user data, game progress, or any information for later.
Simple explanation: Like writing in your notebook – you put the words on paper.
Real‑life example: You save a document in Word – it writes to a file.
School example: You write your homework in a file and save it.
Home example: You write a shopping list and save it on your phone.
Nigerian example: A bank writes transaction details to a file.
Illustration:
file = open("data.txt", "w")
file.write("Hello, this is a saved file.")
file.close()
Mini summary: Use open() with "w" to write to a file.
📘 Lesson 12: Appending to a File
Definition: Appending means adding new data to the end of an existing file.
Why is it important? You can keep adding to a file without losing the old data.
Simple explanation: Like adding new pages to a notebook – the old pages stay.
Real‑life example: You add a new contact to your phone’s contact list file.
School example: The teacher adds new grades to the class record file.
Home example: You add a new item to your shopping list file.
Nigerian example: A bank appends each transaction to a log file.
Illustration:
file = open("data.txt", "a")
file.write("\nNew line added.")
file.close()
Mini summary: Use "a" mode to append data to a file.
📘 Lesson 13: Closing Files – Why It’s Important
Definition: Closing a file means telling the computer you are done using it. This frees up resources.
Why is it important? If you don’t close files, you might lose data or cause errors.
Simple explanation: Like closing a book after you finish reading – it’s polite and helps keep things tidy.
Real‑life example: You close a document after editing to save your changes.
School example: You close your notebook when the lesson is over.
Home example: You close the fridge door to keep food fresh.
Nigerian example: A shopkeeper closes the cash register after counting.
Illustration:
file = open("data.txt", "r")
content = file.read()
file.close() # Always close the file!
Mini summary: Always close files with .close() to save data and free resources.
📘 Lesson 14: Saving and Loading Game Data
Definition: You can save game progress (like level, score, lives) to a file and load it later.
Why is it important? Players can continue where they left off!
Simple explanation: Like saving your place in a book with a bookmark.
Real‑life example: Many video games have a “Save Game” feature.
School example: You save your essay draft to work on it later.
Home example: You save your favorite TV show episodes to watch later.
Nigerian example: A football game saves the team lineup and scores.
Illustration:
# Save
file = open("save.txt", "w")
file.write("Level:3, Lives:5, Score:1200")
file.close()
# Load
file = open("save.txt", "r")
data = file.read()
print("Saved data:", data)
file.close()
Mini summary: Save game data to a file and load it to restore the game state.
📘 Lesson 15: Putting It All Together – A Simple Phonebook
Definition: A phonebook program uses classes and file I/O to store contacts.
Why is it important? It’s a practical example of how classes and files work together.
Simple explanation: You can add contacts, save them to a file, and load them back.
Real‑life example: Your phone’s contact list.
School example: A school directory of students and parents.
Home example: Your family’s contact list.
Nigerian example: A business contact management system.
Illustration:
class Contact:
def __init__(self, name, phone):
self.name = name
self.phone = phone
def display(self):
print(self.name + ": " + self.phone)
# Save contacts to file...
# Load contacts from file...
Mini summary: Classes and files together can build useful real‑world applications.
📚 Key Vocabulary
| Word | Simple Definition |
|---|---|
| Object | A real‑world thing in code with properties and actions. |
| Class | A blueprint for creating objects. |
| Attribute | A property of an object (like a name). |
| Method | An action that an object can perform. |
| __init__ | The constructor – runs when an object is created. |
| Inheritance | A child class inheriting from a parent class. |
| File | A place on the computer to store data permanently. |
| Read | Getting data from a file. |
| Write | Saving data to a file. |
| Append | Adding data to the end of a file. |
class ClassName: to define the class.__init__ to set up attributes.open("filename", "w")..write()..close().open("filename", "r")..read() or .readlines()..close().This module introduces the concept of Object‑Oriented Programming (OOP). Use physical analogies (like cookie cutters) to explain classes and objects. For file handling, demonstrate with simple text files. Encourage students to create their own classes – like a “Student” or “Car” class.
Encourage your child to identify objects in their daily life – every object has properties and actions. Discuss how a “Toy” could be a class, and their specific toys are objects. This helps reinforce the concept of classes and objects.
pickle?self parameter – all methods need self as the first parameter.__init__ correctly – forgetting to set attributes."w" when you meant "a".Player).self to refer to the current object.with open() – it automatically closes the file for you!
+-------------------+
| Class: Car |
+-------------------+
| Attributes: |
| - make |
| - model |
| - speed |
+-------------------+
| Methods: |
| - accelerate() |
| - brake() |
+-------------------+
| |
v v
+--------+ +--------+
| Car 1 | | Car 2 |
| Toyota | | Honda |
| Camry | | Civic |
| 0 km/h | | 0 km/h |
+--------+ +--------+
| Mode | Description |
|---|---|
| "r" | Read – opens a file for reading (file must exist). |
| "w" | Write – opens a file for writing (overwrites if exists). |
| "a" | Append – opens a file for adding data to the end. |
| "r+" | Read and write – can both read and write. |
Start
|
v
Open file
|
v
Read data
|
v
Process data
|
v
Close file
|
v
End
You have completed Module 5 – a massive achievement! You now understand classes and objects – the building blocks of modern programming. You can define your own classes, create objects, and use inheritance to reuse code. You also learned how to save and load data using files, so your programs can remember things between runs.
These skills are used by professional software engineers every day. You can now build programs that model real‑world things and store data permanently. The world of software engineering is now wide open to you!
You are becoming a true software engineer – keep shining!
__init__? It’s a special method that sets up the object when it’s created.self? It refers to the current object. It’s how you access attributes and methods inside the class."r" mean in file opening? It means read – you open the file to read data."w" mean? Write – you open the file to save data (overwriting any existing data)."a" mean? Append – you add data to the end of the file.pickle – but we learn the basics with text files first.__init__ method used for?self?"w" and "a" in file opening?__init__ is a method that runs when an object is created. (True)"r" is used to write to a file. (False)"w" appends data to a file. (False)__init__ do?self used for?class Car()def Car()class Car:object Car()thisselfmeobj| Term | Definition |
|---|---|
| 1. Class | A. An instance of a class |
| 2. Object | B. A blueprint for objects |
| 3. Attribute | C. An action of an object |
| 4. Method | D. A property of an object |
| 5. Inheritance | E. A child class getting features from a parent |
Answers: 1‑B, 2‑A, 3‑D, 4‑C, 5‑E
__init__ method?Scenario 1: You are building a library management system. Create a Book class with attributes title, author, and year. Add a method display() that prints the book’s details. Create two book objects and display them.
Scenario 2: You want to save your library data. Write code to save the book details to a file, and then read them back.
In groups, design a Student class with attributes for name, age, and grade. Create a method that displays the student’s info. Then, write a program that saves a list of students to a file and loads it back. Present your code to the class.
Write a Python program that defines a Pet class with attributes name, species, and age. Include a method describe(). Create three pet objects and store them in a list. Then, save the list to a file and load it back.
Build a Contact Management System: Create a Contact class with attributes name, phone, and email. Implement functions to add, view, and save contacts to a file. Load contacts from the file when the program starts.
Write a Python program that defines a Product class with attributes name, price, and quantity. Include a method to calculate the total value (price * quantity). Create a list of products, and save the list to a file. Then, read the file and display the total value of all products.
Create a BankAccount class with attributes account_number, owner, and balance. Add methods for deposit(), withdraw(), and display(). Save all accounts to a file, and load them when the program starts. Include error handling for insufficient funds.
Fill‑in‑the‑Blank: 1. class, 2. object, 3. __init__, 4. self, 5. Inheritance, 6. "r", 7. "w", 8. "a", 9. close, 10. properties/data.
True/False: 1F, 2T, 3T, 4T, 5F, 6F, 7T, 8T, 9F, 10F.
Multiple Choice: 1B, 2B, 3B, 4B, 5B, 6B, 7A, 8C, 9A, 10B, 11B, 12B, 13C, 14B, 15D.
In Module 6, you will learn about dictionaries, tuples, and error handling. These are advanced data structures and techniques that make your code more robust and powerful. To prepare, think about how you could store key‑value pairs (like a phonebook where the name is the key and the number is the value).
You have come so far – keep learning and building! See you in Module 6!
Hello, brilliant builder! In Module 5, you learned about classes, objects, and files. Now, we are going to explore even more powerful tools in Python – dictionaries, tuples, and error handling.
Imagine you have a phonebook. You look up a name and find a phone number. That is a dictionary – it stores pairs of keys and values. A tuple is like a list, but it cannot be changed – it's a fixed collection.
Sometimes, your program might make a mistake – like trying to divide by zero. Instead of crashing, we can handle errors gracefully and keep the program running.
By the end of this module, you will be able to use these tools to write more efficient and reliable programs. Let's dive in!
After this module, you will be able to:
try/except.Amara ran a small market stall in Lagos. She sold fruits and vegetables. She had a list of items and their prices. But it was hard to find prices quickly – she had to scan the whole list.
Her friend, a software engineer, said: “Use a dictionary! Instead of a list, you can look up the price directly by the item name.”
Amara created a dictionary where the item name was the key and the price was the value. Now she could find any price instantly – like magic!
She also wanted to keep track of her daily sales in a tuple – a fixed record of the day's total. And when she made a mistake entering a price, she learned to handle errors so her program wouldn't crash.
Now, let's learn how to use these tools in Python!
Definition: A dictionary is a collection of key-value pairs. You use a key to look up its value – like a phonebook.
Why is it important? Dictionaries let you store and retrieve data quickly using a unique key.
Simple explanation: Think of a dictionary (the book). You look up a word (the key) and you find its meaning (the value).
Real‑life example: A phonebook – names (keys) and phone numbers (values).
School example: A student ID (key) and the student's name (value).
Home example: A recipe book – dish name (key) and instructions (value).
Nigerian example: A market price list – item name (key) and price (value).
Illustration:
+----------------------+
| Dictionary |
+----------------------+
| Key | Value |
+---------+------------+
| "apple" | 200 |
| "orange"| 150 |
| "banana"| 100 |
+---------+------------+
Mini summary: A dictionary stores key-value pairs for fast lookup.
Definition: You create a dictionary using curly braces {} and separate keys and values with colons :.
Why is it important? This is the syntax you need to create dictionaries in Python.
Simple explanation: You write {"key": "value"}.
Real‑life example: {"Chidi": "08012345678", "Ama": "08087654321"}
School example: {"Math": 85, "English": 90, "Science": 78}
Home example: {"dad": "John", "mom": "Mary", "sister": "Ada"}
Nigerian example: {"Lagos": 15, "Abuja": 10, "Kano": 8} (city population in millions).
Illustration:
prices = {
"apple": 200,
"orange": 150,
"banana": 100
}
print(prices["apple"]) # 200
Mini summary: Use {} to create dictionaries with key-value pairs.
Definition: You access a value by using its key in square brackets [].
Why is it important? This is how you get the data you need from a dictionary.
Simple explanation: Like looking up a word in a dictionary – you use the word to find the meaning.
Real‑life example: phonebook["Chidi"] returns Chidi's phone number.
School example: grades["Math"] returns your Math grade.
Home example: family["dad"] returns your dad's name.
Nigerian example: prices["apple"] returns the price of an apple.
Illustration:
prices = {"apple": 200, "orange": 150}
print(prices["apple"]) # 200
Mini summary: Use the key in [] to get its value.
Definition: You can add a new key-value pair or change an existing value by assigning to the key.
Why is it important? Dictionaries are dynamic – you can update them as needed.
Simple explanation: Like adding a new contact to your phone or updating a phone number.
Real‑life example: Adding a new friend to your contact list.
School example: Updating a grade after a test.
Home example: Adding a new chore to the chore list.
Nigerian example: Adding a new item to your market price list.
Illustration:
prices = {"apple": 200}
prices["orange"] = 150 # adding
prices["apple"] = 250 # changing
print(prices) # {'apple': 250, 'orange': 150}
Mini summary: You can add or change items by assigning to a key.
Definition: You can remove a key-value pair using del or pop().
Why is it important? Sometimes you need to delete data that is no longer needed.
Simple explanation: Like deleting a contact from your phone.
Real‑life example: Removing an old friend from your contact list.
School example: Removing a subject you no longer take.
Home example: Removing a chore that is done.
Nigerian example: Removing an item that is out of stock.
Illustration:
prices = {"apple": 200, "orange": 150}
del prices["apple"] # removes apple
prices.pop("orange") # removes orange
print(prices) # {}
Mini summary: Use del or pop() to remove items.
Definition: You can loop through keys, values, or both using for loops.
Why is it important? This lets you process all the data in a dictionary.
Simple explanation: Like going through each contact in your phonebook.
Real‑life example: Printing all contacts in your phone.
School example: Displaying all your grades for each subject.
Home example: Listing all the chores for the week.
Nigerian example: Displaying all items in a market price list.
Illustration:
prices = {"apple": 200, "orange": 150}
for item, price in prices.items():
print(item, "costs", price, "naira")
Mini summary: Use .items() to loop through key-value pairs.
Definition: A tuple is a collection of items that is immutable – it cannot be changed after creation.
Why is it important? Tuples are useful for data that should not change, like days of the week.
Simple explanation: A tuple is like a list, but you cannot add, remove, or change items.
Real‑life example: The days of the week – Monday to Sunday.
School example: The subjects you take this term – they are fixed.
Home example: Your family members – a fixed set.
Nigerian example: The states in the South‑East – fixed.
Illustration:
days = ("Monday", "Tuesday", "Wednesday")
print(days[0]) # Monday
# days[0] = "Sunday" # ERROR! Cannot change
Mini summary: Tuples are fixed collections that cannot be changed.
Definition: Use a list when you need to change items; use a tuple when you need a fixed collection.
Why is it important? Choosing the right type makes your program more efficient and safer.
Simple explanation: If you have a list of things that might change, use a list. If they are fixed, use a tuple.
Real‑life example: Your shopping list (list) – you add and remove items. The days of the week (tuple) – fixed.
School example: Your class schedule (list) – it can change. The school subjects (tuple) – fixed.
Home example: Your chores (list) – they change. Your family members (tuple) – fixed.
Nigerian example: Items in your cart (list) – they change. The regions in Nigeria (tuple) – fixed.
Illustration:
shopping_list = ["bread", "milk", "eggs"] # list – can change
weekdays = ("Mon", "Tue", "Wed") # tuple – fixed
Mini summary: Lists are for changeable data; tuples are for fixed data.
Definition: Error handling is a way to catch and manage errors so your program doesn't crash.
Why is it important? It makes your program robust – it can handle unexpected situations.
Simple explanation: Like wearing a helmet – it protects you if you fall.
Real‑life example: A vending machine – if you insert a wrong coin, it gives it back instead of breaking.
School example: If you make a mistake on a test, your teacher helps you correct it instead of failing you instantly.
Home example: If you spill water, you clean it up – you don't panic.
Nigerian example: A POS machine – if it can't read your card, it says "try again" instead of crashing.
Illustration:
try:
result = 10 / 0 # This will cause an error!
except ZeroDivisionError:
print("Cannot divide by zero!")
Mini summary: Error handling lets your program recover from mistakes.
try/except BlockDefinition: try and except are used to test a block of code for errors and handle them.
Why is it important? It allows you to catch specific errors and respond appropriately.
Simple explanation: You try to do something, and if it fails, you except (catch) the error and do something else.
Real‑life example: You try to open a door. If it's locked, you use a key (instead of breaking the door).
School example: You try to answer a question. If you don't know, you raise your hand and ask for help.
Home example: You try to cook a new recipe. If it doesn't taste good, you add salt instead of throwing it away.
Nigerian example: You try to withdraw money from an ATM. If the amount is too high, it shows "insufficient balance" instead of crashing.
Illustration:
try:
number = int(input("Enter a number: "))
print("You entered", number)
except ValueError:
print("That's not a valid number!")
Mini summary: try runs code; except catches and handles errors.
Definition: You can catch specific types of errors (like ValueError or ZeroDivisionError) to handle them differently.
Why is it important? It lets you give the user a helpful message instead of a technical error.
Simple explanation: Like a lifeguard – they have different ways to help if you're drowning vs. if you're just tired.
Real‑life example: If a file is not found, you can create it instead of crashing.
School example: If a student enters an invalid answer, the teacher prompts them to try again.
Home example: If you can't find a tool, you look for it instead of giving up.
Nigerian example: If a transaction fails, the app shows a message like "network error" instead of crashing.
Illustration:
try:
result = 10 / int(input("Enter divisor: "))
except ZeroDivisionError:
print("Cannot divide by zero!")
except ValueError:
print("Please enter a number!")
Mini summary: Catch specific errors to give better feedback.
else and finally ClausesDefinition: else runs if no error occurred; finally runs always, whether an error occurred or not.
Why is it important? They help you structure your code neatly and ensure cleanup actions happen.
Simple explanation: else is like “if everything goes well, do this”. finally is like “no matter what, do this”.
Real‑life example: When you try to cook: else – enjoy the meal; finally – clean the kitchen.
School example: When you write a test: else – get a grade; finally – return the paper.
Home example: When you do laundry: else – fold clothes; finally – put detergent away.
Nigerian example: When you shop: else – pay; finally – leave the store.
Illustration:
try:
result = 10 / 2
except ZeroDivisionError:
print("Error!")
else:
print("Result:", result)
finally:
print("Done.")
Mini summary: else runs on success; finally always runs.
Definition: You can use raise to trigger an error on purpose when something is wrong.
Why is it important? It lets you enforce rules in your program – like checking that a value is valid.
Simple explanation: Like a teacher saying “Stop!” if you break a rule.
Real‑life example: A vending machine rejects a fake coin.
School example: A teacher rejects an assignment without a name.
Home example: A parent says “No” if you want candy before dinner.
Nigerian example: A bank app raises an error if you try to transfer more than your balance.
Illustration:
def check_age(age):
if age < 0:
raise ValueError("Age cannot be negative!")
print("Age is", age)
check_age(10) # works
# check_age(-5) # raises an error
Mini summary: Use raise to trigger errors when something is wrong.
Definition: When working with files, you can use error handling to manage missing files or permissions.
Why is it important? It prevents your program from crashing if a file doesn't exist.
Simple explanation: If you try to read a file that doesn't exist, you can create it instead of crashing.
Real‑life example: If a book is missing from the library, you order a new one.
School example: If your notebook is lost, you get a new one.
Home example: If you can't find a recipe, you search online.
Nigerian example: If a customer's record is not in the system, you create a new one.
Illustration:
try:
file = open("data.txt", "r")
content = file.read()
file.close()
except FileNotFoundError:
print("File not found. Creating a new one.")
file = open("data.txt", "w")
file.write("New file created.")
file.close()
Mini summary: Use error handling to manage file operations safely.
Definition: A real program uses dictionaries, tuples, and error handling together to solve problems.
Why is it important? This is how professional software engineers build robust applications.
Simple explanation: You use dictionaries to store data, tuples for fixed data, and error handling to manage mistakes.
Real‑life example: A weather app uses a dictionary to store city‑temperature pairs, tuples for fixed data like months, and error handling for network issues.
School example: A gradebook uses a dictionary for student grades, a tuple for subjects, and error handling for invalid inputs.
Home example: A recipe app uses a dictionary for recipes, a tuple for ingredients that are always needed, and error handling for missing files.
Nigerian example: A banking app uses dictionaries for customer data, tuples for fixed currency types, and error handling for transaction errors.
Illustration:
# Dictionary for prices
prices = {"apple": 200, "orange": 150}
# Tuple for fixed categories
categories = ("Fruits", "Vegetables")
# Error handling for input
try:
item = input("Enter item: ")
print("Price:", prices[item])
except KeyError:
print("Item not found!")
Mini summary: Combining dictionaries, tuples, and error handling creates powerful programs.
| Word | Simple Definition |
|---|---|
| Dictionary | A collection of key-value pairs. |
| Key | A unique identifier used to look up a value. |
| Value | The data associated with a key. |
| Tuple | A fixed, unchangeable collection. |
| Immutable | Cannot be changed after creation. |
| Error Handling | Managing errors to prevent crashes. |
| try/except | Blocks used to catch and handle errors. |
| raise | Trigger an error on purpose. |
| KeyError | Error when a key is not found in a dictionary. |
| ValueError | Error when a value is invalid. |
{key: value}.dict[key].dict[new_key] = value.del dict[key].for key, value in dict.items():.try block.except ErrorType:.else block for success.finally block for cleanup.raise errors to enforce rules.This module introduces powerful data structures and error handling. Use real‑world analogies (phonebooks, contact lists) to explain dictionaries. Emphasise the immutability of tuples. For error handling, demonstrate common errors and how to catch them. Encourage students to write programs that handle errors gracefully.
Encourage your child to think about data as key‑value pairs – e.g., “What is the key for your phone number?”. Discuss the difference between changeable (list) and fixed (tuple) data. Talk about how error handling is like planning for mistakes – it's a sign of a good engineer.
try/except to catch errors.KeyError – when accessing a key that doesn't exist.== instead of = when adding items – assignment vs comparison.Exception – it's better to catch specific errors.finally for cleanup – like closing files..get() to safely access dictionary values (returns None if key missing).except.finally or with.
+--------+ +---------+
| Key | --> | Value |
+--------+ +---------+
| "apple"| | 200 |
| "orange"| | 150 |
| "banana"| | 100 |
+--------+ +---------+
| Feature | List | Tuple | Dictionary |
|---|---|---|---|
| Mutable? | Yes | No | Yes |
| Ordered? | Yes | Yes | Yes (Python 3.7+) |
| Access by | Index | Index | Key |
| Example | [1,2,3] | (1,2,3) | {'a':1} |
+-------------------+
| try block |
| (risky code) |
+--------+----------+
|
+--------v----------+
| Error occurred? |
+---+------------+--+
| |
Yes No
| |
v v
+--------+ +--------+
| except | | else |
| handle | | (done) |
+--------+ +--------+
| |
+------+-----+
|
+------v-----+
| finally |
| (clean up) |
+------------+
You have completed Module 6 – you are now equipped with some of the most powerful tools in Python! You learned about dictionaries – key‑value stores for fast data access. You discovered tuples – fixed collections that are safe and efficient. You also learned error handling – how to make your programs robust and user‑friendly.
These concepts are used in almost every real‑world application – from web apps to games to banking systems. You are building a solid foundation for advanced software engineering.
Keep exploring and practicing – you are doing amazing!
dict[key].try/except? A way to catch and handle errors.KeyError? An error that occurs when you try to access a key that doesn't exist..get(key) – it returns None if the key is missing.raise do? It triggers an error on purpose.try/except block?KeyError?else clause in error handling?finally clause?raise an error?try/except is used for loops. (False)KeyError occurs when you try to access a missing key. (True)finally runs only if an error occurs. (False – it always runs)raise to trigger an error on purpose. (True)[]{}()<>tryexceptfinallyraiseKeyError?raise do?else clause do in error handling?finally clause do?dict[key]dict.get(key)dict.pop(key)del dict[key]| Term | Definition |
|---|---|
| 1. Dictionary | A. A fixed, unchangeable collection |
| 2. Tuple | B. A collection of key‑value pairs |
| 3. KeyError | C. Used to catch errors |
| 4. except | D. Error when a key is missing |
| 5. raise | E. Trigger an error on purpose |
Answers: 1‑B, 2‑A, 3‑D, 4‑C, 5‑E
KeyError?Scenario 1: You are building a dictionary to store student grades. The keys are student names, and the values are grades. Write code to add a new student, update a grade, and safely retrieve a grade.
Scenario 2: You are reading a file that might not exist. Write code that handles the FileNotFoundError and creates the file if it doesn't exist.
In groups, create a dictionary of 10 items and their prices (in naira). Write functions to add, remove, and update items. Then, write a function that displays all items and prices. Use error handling to manage invalid inputs.
Write a Python program that creates a tuple of your favourite foods. Then, create a dictionary that maps each food to its price. Use error handling to check if a user‑entered food is in the dictionary.
Build a Simple Phonebook: Create a program that uses a dictionary to store contacts (name → phone number). Implement functions to add, delete, update, and search for contacts. Use error handling for cases like a contact not found or invalid input.
Write a Python program that reads a text file containing key‑value pairs (one per line, separated by commas). Store them in a dictionary. Then, allow the user to search for a key and display its value. Handle errors if the file doesn't exist or a key is missing.
Write a Python program that creates a nested dictionary – a dictionary where the values are also dictionaries. For example, a dictionary of students, where each student has a dictionary of subjects and grades. Implement functions to add a student, add a grade, and calculate the average grade for a student. Use error handling for all operations.
Fill‑in‑the‑Blank: 1. dictionary, 2. key, 3. tuple, 4. immutable, 5. Error handling, 6. try/except, 7. KeyError, 8. raise, 9. else, 10. finally.
True/False: 1F, 2F, 3F, 4T, 5F, 6T, 7F, 8T, 9T, 10F.
Multiple Choice: 1B, 2B, 3B, 4B, 5B, 6A, 7B, 8B, 9B, 10C, 11B, 12B, 13B, 14D, 15B.
In Module 7, you will learn about recursion, higher‑order functions, and working with JSON. These are advanced topics that will take your Python skills to the next level. To prepare, think about problems that can be broken down into smaller versions of themselves – like searching a folder inside a folder.
You are on an incredible journey – keep going! See you in Module 7!
Hello, amazing engineer! You have come so far – you now know variables, loops, functions, classes, dictionaries, and error handling. In this module, we are going to explore three powerful concepts that will make you a true Python master!
Recursion is when a function calls itself. It's like looking at yourself in a mirror that reflects another mirror – you see yourself inside yourself!
Lambda functions are tiny, one‑line functions that you can use on the spot – like a quick note instead of a full letter.
JSON (JavaScript Object Notation) is a way to store and exchange data – it's like a universal language that computers all over the world understand.
By the end of this module, you will be able to write recursive functions, use lambdas, and read/write JSON data. These are advanced skills used by professional developers every day!
After this module, you will be able to:
map(), filter(), and sorted().Ngozi loved playing with Russian dolls – those wooden dolls that open to reveal a smaller doll inside, and then another, and another.
One day, she thought: “If I could write a program that opens each doll until it reaches the smallest one, that would be like a function calling itself!”
Her older brother, a software engineer, explained: “That’s called recursion. You have a function that opens a doll. If there’s a smaller doll inside, it calls itself again. This continues until it reaches the smallest doll – that’s the base case.”
Ngozi also learned about lambda – tiny functions that are so small you don't even need to name them – like a quick note. And JSON – a way to store her doll collection data so she could share it with friends.
Let's learn these amazing tools!
Definition: Recursion is a technique where a function calls itself to solve a smaller version of the same problem.
Why is it important? It's a very elegant way to solve problems that can be broken down into smaller, similar problems.
Simple explanation: Like the Russian dolls – you open one, and inside is a smaller one, until you reach the tiny one at the centre.
Real‑life example: Looking for a book in a stack of boxes – you open one box, if it's not there, you open the next, and so on.
School example: Counting the number of students in a row – you count the first student, then the rest of the row.
Home example: Peeling an onion – you peel one layer, then peel the next.
Nigerian example: Finding your way in a market – you ask one trader, they point to another, and so on.
Illustration:
def open_doll():
if there_is_a_smaller_doll():
open_doll() # calls itself!
else:
print("Reached the smallest doll!")
Mini summary: Recursion is when a function calls itself to solve a smaller version of the same problem.
Definition: The base case is the condition that stops the recursion. The recursive case is where the function calls itself.
Why is it important? Without a base case, the function would call itself forever – causing a stack overflow!
Simple explanation: The base case is like the smallest doll – you stop when you reach it. The recursive case is like opening a doll to find another doll inside.
Real‑life example: Countdown to zero – you start at 10, then 9, then 8, and when you reach 0 (base case), you stop.
School example: A teacher calling students' names – when they reach the last name (base case), they stop.
Home example: Eating a chocolate bar – you break off pieces until you have eaten the last piece (base case).
Nigerian example: Passing a message down a line of people – when the last person gets it (base case), the chain stops.
Illustration:
def countdown(n):
if n == 0: # base case
print("Blast off!")
else: # recursive case
print(n)
countdown(n-1)
Mini summary: The base case stops recursion; the recursive case calls the function again.
Definition: Factorial (written as n!) is the product of all positive integers up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
Why is it important? It's a classic example that shows how recursion works beautifully.
Simple explanation: 5! = 5 × 4! – so factorial calls itself with a smaller number.
Real‑life example: Arranging 5 books on a shelf – there are 5! ways to arrange them.
School example: How many ways can you arrange 3 students in a row? 3! = 6 ways.
Home example: How many ways can you arrange 4 chairs around a table? 4! = 24 ways.
Nigerian example: How many ways can you arrange 5 different fruits in a basket? 5! = 120 ways.
Illustration:
def factorial(n):
if n == 0: # base case
return 1
else: # recursive case
return n * factorial(n-1)
print(factorial(5)) # 120
Mini summary: Factorial is a perfect example – it calls itself with a smaller number until it reaches 0.
Definition: Fibonacci numbers are a sequence where each number is the sum of the two preceding ones: 0, 1, 1, 2, 3, 5, 8, 13, ...
Why is it important? It shows how recursion can solve problems that are naturally recursive.
Simple explanation: fib(n) = fib(n-1) + fib(n-2) – the function calls itself twice!
Real‑life example: The number of rabbits in a population after n months – each pair produces a new pair.
School example: The number of ways to climb stairs if you can take 1 or 2 steps at a time.
Home example: The number of ancestors you have going back n generations (roughly).
Nigerian example: The branching pattern of a tree – each branch splits into smaller branches.
Illustration:
def fibonacci(n):
if n <= 1: # base case
return n
else: # recursive case
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(6)) # 8
Mini summary: Fibonacci is a recursive sequence – each term is the sum of the two previous terms.
Definition: Recursion solves problems by calling itself; iteration solves them using loops (like for and while).
Why is it important? Sometimes recursion is simpler, sometimes loops are more efficient.
Simple explanation: Recursion is like climbing down a ladder (one step at a time, going deeper). Iteration is like walking down a hallway (repeating a step).
Real‑life example: Finding a file in a folder (recursion) vs adding up numbers in a list (iteration).
School example: Checking each student in a list (iteration) vs calculating factorial (recursion).
Home example: Eating a cake slice by slice (iteration) vs opening Russian dolls (recursion).
Nigerian example: Counting passengers on a bus (iteration) vs navigating a maze (recursion).
Illustration:
# Iterative factorial
def factorial_iter(n):
result = 1
for i in range(1, n+1):
result = result * i
return result
# Recursive factorial
def factorial_rec(n):
if n == 0:
return 1
return n * factorial_rec(n-1)
Mini summary: Recursion and iteration are both ways to repeat – recursion is often more elegant, iteration is often faster.
Definition: A lambda is a small, anonymous function – it has no name and is defined in one line.
Why is it important? It's useful for short, simple operations that you don't want to define as a full function.
Simple explanation: Like a quick note you write on a sticky note – you use it and throw it away.
Real‑life example: Writing a quick formula on a scrap of paper.
School example: Jotting down a quick reminder.
Home example: Writing a shopping list on a small piece of paper.
Nigerian example: A trader writing a quick price on a label.
Illustration:
# A normal function
def add(a, b):
return a + b
# A lambda function (same thing, but one line)
add_lambda = lambda a, b: a + b
print(add_lambda(5, 3)) # 8
Mini summary: A lambda is a one‑line, nameless function for short tasks.
map()Definition: map() applies a function to every item in an iterable (like a list).
Why is it important? It's a clean way to transform data without writing loops.
Simple explanation: You have a list of numbers; you want to double each one. map() does it for you!
Real‑life example: A price list – you apply a 10% discount to every item.
School example: You have a list of test scores; you add 5 points to each.
Home example: You have a list of ingredients; you convert cups to grams.
Nigerian example: A trader updates prices by adding 50 naira to each item.
Illustration:
numbers = [1, 2, 3, 4, 5]
doubled = map(lambda x: x * 2, numbers)
print(list(doubled)) # [2, 4, 6, 8, 10]
Mini summary: map() with lambda applies a function to every item in a list.
filter()Definition: filter() selects items from an iterable based on a condition.
Why is it important? It's an easy way to filter data – like keeping only the good apples.
Simple explanation: You have a list of numbers; you want only the even ones. filter() does it!
Real‑life example: A shopkeeper checks which items are in stock.
School example: A teacher finds all students who scored above 80.
Home example: You filter out chores that are already done.
Nigerian example: A trader filters out items that are out of stock.
Illustration:
numbers = [1, 2, 3, 4, 5, 6]
evens = filter(lambda x: x % 2 == 0, numbers)
print(list(evens)) # [2, 4, 6]
Mini summary: filter() with lambda selects items that satisfy a condition.
sorted()Definition: sorted() sorts an iterable. You can use a lambda to specify how to sort.
Why is it important? It lets you sort by custom rules – like sorting by the second item in a tuple.
Simple explanation: You have a list of people with ages. You want to sort them by age – sorted() with a lambda does it!
Real‑life example: Sorting a list of students by their scores.
School example: Arranging books by page count.
Home example: Sorting your grocery list by price.
Nigerian example: Sorting market items by price per kilogram.
Illustration:
fruits = [("apple", 200), ("orange", 150), ("banana", 100)]
sorted_fruits = sorted(fruits, key=lambda x: x[1])
print(sorted_fruits) # [('banana', 100), ('orange', 150), ('apple', 200)]
Mini summary: sorted() with a lambda lets you sort by custom criteria.
Definition: JSON (JavaScript Object Notation) is a lightweight format for storing and exchanging data.
Why is it important? It's the most common way to send data between web servers and apps.
Simple explanation: It's like a universal language that computers use to talk to each other.
Real‑life example: When you use a weather app, it gets data from a server in JSON format.
School example: A student database stored as JSON.
Home example: A shopping list stored as JSON.
Nigerian example: A fintech app receives transaction data in JSON.
Illustration:
{
"name": "Chidi",
"age": 10,
"city": "Lagos",
"grades": [85, 90, 78]
}
Mini summary: JSON is a standard format for storing and exchanging data.
json ModuleDefinition: Python has a json module that lets you convert Python objects to JSON and vice versa.
Why is it important? It allows your Python programs to communicate with web services.
Simple explanation: You can turn a Python dictionary into a JSON string, and turn a JSON string back into a Python dictionary.
Real‑life example: Saving user settings in a JSON file.
School example: Storing student records in a JSON file.
Home example: Saving a recipe in JSON format.
Nigerian example: A bank app sending transaction data as JSON.
Illustration:
import json
data = {"name": "Chidi", "age": 10}
json_string = json.dumps(data) # convert to JSON
print(json_string) # {"name": "Chidi", "age": 10}
parsed = json.loads(json_string) # convert back to Python
print(parsed["name"]) # Chidi
Mini summary: The json module converts between Python objects and JSON.
Definition: You can save JSON data to a file and read it back later.
Why is it important? It's a common way to store configuration and data.
Simple explanation: Like saving your game progress in a file – but in JSON format.
Real‑life example: A game saves your high score in a JSON file.
School example: A teacher saves student grades in a JSON file.
Home example: You save your favourite recipes in a JSON file.
Nigerian example: A POS machine saves daily transactions in a JSON file.
Illustration:
import json
data = {"name": "Chidi", "score": 100}
# Write to file
with open("data.json", "w") as file:
json.dump(data, file)
# Read from file
with open("data.json", "r") as file:
loaded_data = json.load(file)
print(loaded_data["name"]) # Chidi
Mini summary: Use json.dump() and json.load() to work with JSON files.
Definition: JSON supports dictionaries (objects) and lists (arrays) – just like Python!
Why is it important? You can store complex nested data structures.
Simple explanation: You can have a list of dictionaries – like a list of students, each with their own details.
Real‑life example: A list of products, each with a name, price, and quantity.
School example: A list of students, each with a name and grades.
Home example: A list of family members, each with a name and age.
Nigerian example: A list of transactions, each with an amount and date.
Illustration:
import json
students = [
{"name": "Chidi", "grade": 85},
{"name": "Ama", "grade": 90}
]
# Convert to JSON string
json_data = json.dumps(students)
print(json_data)
# [{"name": "Chidi", "grade": 85}, {"name": "Ama", "grade": 90}]
Mini summary: JSON can store nested data – dictionaries inside lists, and vice versa.
Definition: Each tool has its best use cases – recursion for naturally recursive problems, lambda for short operations, JSON for data exchange.
Why is it important? Knowing when to use each tool makes you a better engineer.
Simple explanation: Use recursion for problems that break into smaller versions of themselves. Use lambda for quick, one‑time functions. Use JSON for storing and sharing data.
Real‑life example: A file system (recursion) – searching through folders and sub‑folders.
School example: Calculating factorial (recursion), filtering a list (lambda), saving grades (JSON).
Home example: Organising a closet (recursion), quick calculations (lambda), storing recipes (JSON).
Nigerian example: Navigating a market (recursion), applying discounts (lambda), storing transaction data (JSON).
Illustration:
# Recursion: traversing a folder
# Lambda: sorting a list by a key
# JSON: storing user data
Mini summary: Choose the right tool – recursion for nested problems, lambda for short functions, JSON for data storage.
Definition: You can combine recursion, lambda, and JSON in a single program.
Why is it important? Real‑world programs use multiple techniques together.
Simple explanation: You might use recursion to explore a nested structure, lambdas to filter data, and JSON to save the results.
Real‑life example: A program that explores a nested folder structure, filters files by size, and saves the results in JSON.
School example: A program that calculates grades recursively, filters students with lambdas, and saves the data in JSON.
Home example: A program that organises a recipe book using recursion (categories), filters recipes with lambdas, and saves in JSON.
Nigerian example: A financial app that recursively calculates compound interest, filters transactions, and stores data in JSON.
Illustration:
# Recursive function to explore nested data
# Lambda to filter items
# JSON to save and load data
Mini summary: Recursion, lambda, and JSON often work together in real programs.
| Word | Simple Definition |
|---|---|
| Recursion | When a function calls itself. |
| Base Case | The condition that stops recursion. |
| Recursive Case | The part where the function calls itself. |
| Lambda | A small, unnamed function. |
| map() | Applies a function to every item in a list. |
| filter() | Selects items that satisfy a condition. |
| sorted() | Sorts items based on a key. |
| JSON | A standard format for data exchange. |
| dumps() | Converts Python object to JSON string. |
| loads() | Converts JSON string to Python object. |
json module.json.dumps() to convert a Python object to a JSON string.json.loads() to convert a JSON string to a Python object.json.dump() to write JSON to a file.json.load() to read JSON from a file.This module introduces three advanced topics. For recursion, use visual aids (Russian dolls, nested boxes). For lambdas, compare them to quick notes. For JSON, show how data is exchanged between apps. Emphasise the importance of the base case in recursion to avoid infinite loops.
Ask your child to identify recursion in daily life – like nested boxes or Russian dolls. Discuss how a quick note is like a lambda function. Explain how data is stored in JSON – like a digital notebook. Encourage them to experiment with small recursive functions.
json module – you must import it to use JSON.with open() when working with JSON files – it handles closing the file.
Start
|
v
Is base case true? → Yes → Return result
|
No
|
v
Call function with smaller input
|
v
(go back to start)
| Feature | Recursion | Iteration |
|---|---|---|
| Definition | Function calls itself | Uses loops (for, while) |
| Code | Often shorter, more elegant | Often longer |
| Performance | Can be slower (function call overhead) | Usually faster |
| Risk | Stack overflow if no base case | Infinite loop if condition never false |
{
"student": {
"name": "Chidi",
"age": 10,
"subjects": ["Math", "Science"]
}
}
You have completed Module 7 – you are now a Python expert! You learned about recursion – functions that call themselves to solve problems elegantly. You discovered lambda functions – small, anonymous functions that are perfect for quick operations. And you mastered JSON – the universal language for data exchange.
These are advanced tools that are used in many real‑world applications – from AI to web development. You now have a powerful toolkit that will serve you for years to come.
You are now ready for the next stage – Module 8 will be a final project where you'll build something amazing!
map()? Applies a function to every item in an iterable.filter()? Selects items from an iterable based on a condition.json.dumps().json.loads().map() with a lambda?filter() with a lambda?json.dumps() and json.dump()?json.loads() and json.load()?map() returns a list. (False – it returns an iterator)filter() returns an iterator. (True)json.dumps() writes JSON to a file. (False – it returns a string)json.load() reads JSON from a file. (True)map() do?filter() do?json.load()json.dumps()json.dump()json.loads()json.load()json.dumps()json.dump()json.loads()json.dump() do?json.load() do?lambda x: x*2lambda x: return x*2lambda(x): x*2lambda x, y: x+y| Term | Definition |
|---|---|
| 1. Recursion | A. A small, anonymous function |
| 2. Lambda | B. A function that calls itself |
| 3. Base Case | C. Converts Python to JSON string |
| 4. dumps() | D. Stops recursion |
| 5. JSON | E. A standard data format |
Answers: 1‑B, 2‑A, 3‑D, 4‑C, 5‑E
json.dumps() and json.dump()?map() and filter()?Scenario 1: You have a nested list of numbers (like [1, [2, [3, 4]], 5]). Write a recursive function that prints all the numbers in the list.
Scenario 2: You have a list of students, each represented as a dictionary. Use a lambda with sorted() to sort them by their grades.
Scenario 3: You want to save a list of transactions to a JSON file and then read it back. Write the code to do this.
In groups, create a recursive function to calculate the sum of all numbers in a nested list. Then, use a lambda with filter() to extract only even numbers from a list. Finally, save the results to a JSON file. Each group presents their code and explains how they used recursion, lambda, and JSON.
Write a Python program that uses recursion to calculate the factorial of a number. Then, use a lambda with map() to calculate the factorial of a list of numbers. Finally, save the results to a JSON file.
Build a Recursive JSON Explorer: Write a Python program that loads a JSON file, recursively traverses the data, and prints all the keys and values in a readable format. Use recursion to handle nested dictionaries and lists. Save the output to a new JSON file.
Write a Python program that reads a JSON file containing a list of products (each with name, price, and quantity). Use a lambda with filter() to find products with a price below 100. Then, use a lambda with map() to apply a 10% discount to those products. Save the updated list to a new JSON file.
Write a Python program that uses recursion to generate all possible combinations of items from a list (like a power set). For example, for [1, 2, 3], the output should be [[], [1], [2], [3], [1,2], [1,3], [2,3], [1,2,3]]. Save the result to a JSON file.
Fill‑in‑the‑Blank: 1. Recursion, 2. base, 3. lambda, 4. map(), 5. filter(), 6. JSON, 7. json.dumps(), 8. json.loads(), 9. json.dump(), 10. json.load().
True/False: 1T, 2F, 3F, 4T, 5T, 6F, 7F, 8T, 9F, 10T.
Multiple Choice: 1B, 2B, 3B, 4B, 5B, 6B, 7B, 8D, 9B, 10D, 11B, 12C, 13B, 14B, 15A.
Module 8 is a final project where you will build a complete application using everything you have learned! You will design, code, test, and present a project of your choice. To prepare, think about what you would like to build – a game? A weather app? A contact manager? Bring your ideas to the next class!
You are now a true software engineer – congratulations! See you in Module 8!
Congratulations, software engineer! You have reached the final module of this course. You have learned so much – variables, loops, functions, classes, dictionaries, recursion, JSON, and much more. Now it's time to put it all together and build something amazing!
In this module, you will create your very own final project – a complete application that solves a real problem or does something fun. You will design it, code it, test it, and present it to others.
This is your chance to be a real software engineer – to take an idea from your head and turn it into a working program. Don't worry – we will guide you step by step.
Let's build something awesome!
After this module, you will be able to:
Chioma had a big idea. She loved reading books, but she always forgot which books she had read and which she wanted to read. She wanted to build a program to keep track of her books.
She thought: “I can build a Book Manager app! It will let me add books, mark them as read, and search for books. I can even save my data in a JSON file.”
Chioma started by planning – she drew a flowchart, wrote down the features, and designed the user interface (text‑based). Then she wrote the code step by step, testing each part along the way.
When she finished, she had a working app that she was proud of. She showed it to her friends and family, and they were impressed. Chioma had become a real software engineer!
Now, it's your turn to build your own app!
Definition: A project is a planned piece of work that has a beginning, a middle, and an end. It produces a final product – in our case, a working program.
Why is it important? Building a project shows that you can apply everything you've learned to create something real.
Simple explanation: A project is like building a Lego model – you plan it, follow instructions (or make your own), and end up with a finished creation.
Real‑life example: Building a treehouse – you plan, gather materials, build, and enjoy the final product.
School example: A science fair project – you choose a topic, research, experiment, and present.
Home example: Redecorating your room – you choose a theme, pick colors, arrange furniture.
Nigerian example: Setting up a small shop – you plan the layout, stock items, and open for business.
Illustration:
Project Idea
|
V
Make Plan
|
V
Do Work
|
V
Finish Project
|
V
Celebrate 🎉
Mini summary: A project is a planned effort that results in a finished product.
Definition: A project idea is a problem you want to solve or something cool you want to create.
Why is it important? You need a clear idea before you can start building.
Simple explanation: Think about what you enjoy doing – maybe it's games, books, music, sports, or helping people. What could you build that relates to that?
Real‑life example: You love cooking – build a recipe manager.
School example: You want to keep track of homework – build a homework manager.
Home example: You want to organise your chores – build a chore tracker.
Nigerian example: You want to help traders – build a market price tracker.
Illustration:
+---------------------------------+
| What do you like? |
| Games? Books? Music? Sports? |
+---------------------------------+
|
v
+---------------------------------+
| What problem can you solve? |
| Organising? Tracking? Sharing? |
+---------------------------------+
|
v
+---------------------------------+
| Your Project Idea! |
+---------------------------------+
Mini summary: Choose a project that solves a problem or does something you enjoy.
Definition: Planning means writing down what your project will do, how it will work, and what features it will have.
Why is it important? A good plan helps you stay focused and avoid confusion.
Simple explanation: Like drawing a map before a journey – you know where you are going.
Real‑life example: An architect draws a blueprint before building a house.
School example: You outline your essay before writing it.
Home example: You write a shopping list before going to the market.
Nigerian example: A trader plans what items to buy before a market trip.
Illustration:
Project Plan:
- Name: Book Manager
- Features:
- Add a book (title, author, year)
- List all books
- Mark a book as read
- Search for a book
- Save to JSON file
- Load from JSON file
Mini summary: Planning is essential – write down what your project will do.
Definition: The user interface is how the user interacts with your program – menus, prompts, and outputs.
Why is it important? A good UI makes your program easy and enjoyable to use.
Simple explanation: It's like the dashboard of a car – it shows you information and lets you control the car.
Real‑life example: A banking app has a screen where you can see your balance and make transactions.
School example: The school portal has a menu where you can check grades and attendance.
Home example: A smart TV remote – buttons for volume, channel, and power.
Nigerian example: A POS machine screen – it shows options for withdrawal, balance check, and transfer.
Illustration:
+--------------------------------------+
| Welcome to Book Manager! |
| Choose an option: |
| 1. Add a book |
| 2. List all books |
| 3. Mark a book as read |
| 4. Search for a book |
| 5. Save and exit |
+--------------------------------------+
| Enter your choice: 1 |
+--------------------------------------+
| Enter title: The Alchemist |
| Enter author: Paulo Coelho |
| Enter year: 1988 |
+--------------------------------------+
| Book added successfully! |
+--------------------------------------+
Mini summary: The UI is how users interact with your program – make it clear and simple.
Definition: Pseudo‑code is a plain‑language description of your program's steps.
Why is it important? It helps you plan the logic before you write actual code.
Simple explanation: Like writing a recipe in your own words before you start cooking.
Real‑life example: A teacher writes a lesson plan before teaching.
School example: You write a draft of your essay before the final copy.
Home example: You write a to‑do list for the day.
Nigerian example: A contractor writes a work plan before starting construction.
Illustration:
Pseudo-code for adding a book:
Function add_book():
Ask user for title
Ask user for author
Ask user for year
Create a dictionary with title, author, year
Add dictionary to the books list
Print "Book added!"
Pseudo-code for listing books:
Function list_books():
For each book in books:
Print title, author, year
Mini summary: Pseudo‑code is a draft of your program – it helps you plan the logic.
Definition: You build your project in small, manageable steps – test each step before moving on.
Why is it important? It makes debugging easier and keeps you from getting overwhelmed.
Simple explanation: Like building a Lego set – you follow the instructions step by step.
Real‑life example: Building a house – you lay the foundation, then the walls, then the roof.
School example: Writing an essay – introduction, body paragraphs, conclusion.
Home example: Cooking a meal – prepare ingredients, cook, serve.
Nigerian example: Building a market stall – set up the frame, add shelves, stock items.
Illustration:
Step 1: Create the main menu
Step 2: Add function to add a book
Step 3: Add function to list books
Step 4: Add function to mark a book as read
Step 5: Add function to search for a book
Step 6: Add save/load to JSON
Step 7: Test everything
Mini summary: Build your project step by step – test each part as you go.
Definition: Use functions to organise your code – each function should do one thing well.
Why is it important? It makes your code clean, readable, and easy to debug.
Simple explanation: Like having a separate drawer for each type of tool – you know where to find things.
Real‑life example: A chef has different stations – one for chopping, one for cooking, one for plating.
School example: Your notebook has different sections for different subjects.
Home example: Your room has different areas – bed, desk, closet.
Nigerian example: A market has different sections – fruit section, vegetable section, meat section.
Illustration:
def display_menu():
# Show menu options
def add_book():
# Add a book to the list
def list_books():
# Print all books
def mark_read():
# Mark a book as read
def search_books():
# Search for a book
Mini summary: Use functions to keep your code organised and easy to manage.
Definition: Use lists to store collections of books, and dictionaries to store each book's details.
Why is it important? This is how you manage data in your program.
Simple explanation: A list is like a shelf; a dictionary is like a label on each item.
Real‑life example: A library – a shelf (list) of books, each with a title, author, and year (dictionary).
School example: A class list – a list of students, each with a name and grade (dictionary).
Home example: A shopping list – a list of items, each with a name and price (dictionary).
Nigerian example: A market inventory – a list of products, each with a name and price (dictionary).
Illustration:
books = [] # empty list
book1 = {
"title": "The Alchemist",
"author": "Paulo Coelho",
"year": 1988,
"read": False
}
books.append(book1)
Mini summary: Use lists to store collections and dictionaries to store item details.
Definition: Use JSON to save your books to a file and load them when the program starts.
Why is it important? This makes your data persistent – it's not lost when you close the program.
Simple explanation: Like writing your book list in a notebook – you can read it later.
Real‑life example: A game saves your progress in a file.
School example: Your teacher saves your grades in a file.
Home example: You save your favourite recipes in a file.
Nigerian example: A trader saves daily sales in a file.
Illustration:
import json
# Save
def save_books(books):
with open("books.json", "w") as file:
json.dump(books, file)
# Load
def load_books():
try:
with open("books.json", "r") as file:
return json.load(file)
except FileNotFoundError:
return []
Mini summary: JSON makes your data persistent – it saves and loads easily.
Definition: Testing means checking if your program works as expected. Debugging means finding and fixing errors.
Why is it important? It ensures your program is reliable and works correctly.
Simple explanation: Like tasting your food while cooking – you adjust the seasoning as needed.
Real‑life example: A pilot checks the plane before takeoff.
School example: You review your test answers before submitting.
Home example: You test a new recipe before serving guests.
Nigerian example: A trader counts money at the end of the day to check for errors.
Illustration:
Test cases:
1. Add a book → check if it appears in the list
2. List books → check if all books are shown
3. Mark as read → check if status changes
4. Search → check if correct books are found
5. Save/load → check if data is preserved
Mini summary: Test your program thoroughly – find and fix bugs before you finish.
Definition: Use try/except to handle errors – like when a file is missing or a user enters invalid input.
Why is it important? It makes your program robust – it won't crash unexpectedly.
Simple explanation: Like wearing a seatbelt – it protects you if something goes wrong.
Real‑life example: An ATM shows a message if your card is invalid instead of crashing.
School example: A quiz app shows a message if you enter an invalid answer.
Home example: A smart speaker says "I didn't understand that" instead of crashing.
Nigerian example: A POS machine shows "Insufficient balance" instead of crashing.
Illustration:
try:
title = input("Enter title: ")
if title == "":
raise ValueError("Title cannot be empty!")
except ValueError as e:
print("Error:", e)
Mini summary: Error handling makes your program safe and user‑friendly.
Definition: Documentation is written information about your program – how to use it and how it works.
Why is it important? It helps others (and your future self) understand and use your program.
Simple explanation: Like a user manual that comes with a new toy.
Real‑life example: A phone comes with a user guide.
School example: Your teacher gives you a syllabus at the start of the term.
Home example: A recipe card has instructions on how to cook.
Nigerian example: A product has a label with usage instructions.
Illustration:
Book Manager - User Guide
=========================
1. Add a book: Enter title, author, year.
2. List books: Shows all books.
3. Mark as read: Mark a book as read.
4. Search: Search for a book by title.
5. Save and exit: Saves data and exits.
Mini summary: Documentation helps others understand and use your program.
Definition: Presenting means showing your project to others – explaining what it does, how it works, and how you built it.
Why is it important? It builds your confidence and helps you get feedback.
Simple explanation: Like show‑and‑tell in school – you show what you made and talk about it.
Real‑life example: A product launch – you show the product and explain its features.
School example: A science fair – you present your project to judges and visitors.
Home example: You show your family a drawing you made.
Nigerian example: A trader explains the quality of their goods to customers.
Illustration:
Presentation Plan:
1. Introduce yourself
2. Show your project (run the program)
3. Explain the features
4. Show the code (if time)
5. Talk about what you learned
6. Ask for questions and feedback
Mini summary: Presenting your project is a great way to share your work and get feedback.
Definition: Reflection means thinking about what you learned, what you enjoyed, and what you found challenging.
Why is it important? It helps you understand your progress and areas for improvement.
Simple explanation: Like looking back at a journey – you see how far you've come.
Real‑life example: You look back at a sports game and think about what went well and what you could do better.
School example: You reflect on a school term – what you learned and what you want to improve.
Home example: You think about a project you completed at home – what you enjoyed and what was tough.
Nigerian example: A trader reflects on the month's sales – what sold well and what didn't.
Illustration:
Reflection Questions:
- What did I learn in this course?
- What was the most fun part?
- What was the most challenging part?
- What would I do differently next time?
- What do I want to learn next?
Mini summary: Reflection helps you appreciate your growth and plan for the future.
Definition: Software engineering is a lifelong journey. You have built a strong foundation – now you can go deeper.
Why is it important? The world of technology is always changing – there is always something new to learn.
Simple explanation: Like learning to ride a bike – now you can explore new roads and go further.
Real‑life example: Many software engineers keep learning new languages and frameworks throughout their careers.
School example: After learning the basics of math, you learn algebra, geometry, and calculus.
Home example: After learning to cook simple meals, you learn new recipes and techniques.
Nigerian example: After learning to trade in one market, you learn about other markets and new products.
Illustration:
Next Steps:
- Learn a new programming language (like JavaScript or Java)
- Build a web application
- Learn about databases
- Contribute to open‑source projects
- Join a coding community
- Keep building projects!
Mini summary: The journey doesn't end here – keep learning and building!
| Word | Simple Definition |
|---|---|
| Project | A planned piece of work with a final product. |
| Plan | A detailed outline of what you will do. |
| User Interface (UI) | How users interact with your program. |
| Pseudo‑code | A plain‑language description of your program. |
| Testing | Checking if your program works correctly. |
| Debugging | Finding and fixing errors. |
| Documentation | Written information about your program. |
| Presentation | Showing and explaining your project. |
| Reflection | Thinking about what you learned. |
| Persistence | Data that is saved and not lost. |
This module is a culmination of the entire course. Encourage students to choose a project they are passionate about. Provide guidance on planning, but allow them to make their own decisions. Celebrate their achievements – this is a big milestone! Use this module to reinforce all the concepts they have learned.
Encourage your child to take ownership of their project. Ask them what they want to build and why. Help them break down the project into smaller steps. Celebrate their progress and final product. This is a great opportunity to show your interest and support.
+------------------+
| Idea |
+--------+---------+
|
+--------v---------+
| Plan |
+--------+---------+
|
+--------v---------+
| Build |
+--------+---------+
|
+--------v---------+
| Test |
+--------+---------+
|
+--------v---------+
| Deploy |
+--------+---------+
|
+--------v---------+
| Maintain |
+------------------+
| Project Type | Features | Data Storage |
|---|---|---|
| Book Manager | Add, list, mark read, search | JSON |
| To‑Do List | Add, complete, delete | JSON |
| Grade Tracker | Add, average, display | JSON |
| Inventory System | Add, update, search | JSON |
[ ] Project plan is clear
[ ] Code is organised with functions
[ ] Error handling is present
[ ] Data is saved to JSON
[ ] Program runs without errors
[ ] User interface is clear and easy to use
[ ] Documentation is included
[ ] Project was presented
You have completed Module 8 – the final module of this course! You have planned, built, tested, and presented your very own software project. You have applied everything you learned – from variables to JSON to recursion. You are now a true software engineer.
This course has given you a strong foundation in programming and software engineering. You can now write clean, organised, and functional code. You can solve problems, debug errors, and build useful applications.
Remember, this is just the beginning. The world of software engineering is vast and exciting. Keep learning, keep building, and keep sharing your work with others.
Thank you for being part of this course – you are amazing!
json and math.| Term | Definition |
|---|---|
| 1. Project | A. Written information about the program |
| 2. Plan | B. Checking if the code works |
| 3. Testing | C. A planned piece of work |
| 4. Documentation | D. How users interact with the program |
| 5. UI | E. A detailed outline of what you will do |
Answers: 1‑C, 2‑E, 3‑B, 4‑A, 5‑D
Scenario 1: You have an idea for a project – a recipe manager. Write a plan for this project. Include features, user interface, and pseudo‑code for at least two functions.
Scenario 2: You have built your project, but it crashes when you try to save data. How would you debug this? What error handling would you add?
In groups, brainstorm a project idea. Create a detailed plan – features, UI, pseudo‑code. Then, divide the work among group members. Build the project together, test it, and present it to the class. This is a great way to practice teamwork!
Choose a project idea that excites you. Plan it, build it, and test it. Then, write a short reflection on what you learned. Present your project to the class or to your family.
This is your final project! Choose one of the following ideas or create your own:
Build your final project using everything you have learned. Your program should include:
Extend your project with a bonus feature:
Fill‑in‑the‑Blank: 1. project, 2. Planning, 3. user interface, 4. Pseudo‑code, 5. Testing, 6. Debugging, 7. Documentation, 8. Presenting, 9. Reflection, 10. JSON.
True/False: 1F, 2T, 3F, 4T, 5F, 6T, 7F, 8T, 9F, 10T.
Multiple Choice: 1B, 2B, 3A, 4B, 5B, 6A, 7B, 8B, 9B, 10D, 11A, 12B, 13B, 14B, 15C.
You have completed the Advanced Software Engineer course! But your journey doesn't end here. Here are some ideas for what to do next:
Congratulations, software engineer! The world is waiting for your creations. Go build something amazing!