Module One: Welcome to Python Programming โ Your First Steps into Coding
Hello, young coder! Welcome to the wonderful world of programming. Have you ever wanted to make a computer do what you want? Have you ever wondered how video games, apps, and websites are made? The secret is programming โ and Python is one of the best languages to start with.
Python is a programming language that is easy to read, easy to write, and very powerful. It is used by scientists, game developers, web builders, and even astronauts! In this first module, we will start from the very beginning. We will learn what programming is, why Python is so popular, and how to write our very first programs. We will use simple words, fun examples, and lots of practice. By the end of this module, you will be able to write your own Python programs and understand the basic building blocks of coding. Let's start your coding adventure!
After completing this module, you will be able to:
Ada's First Code
Ada was 10 years old and loved solving puzzles. One day, her older brother showed her something amazing โ a program that could greet people by name. He typed: print("Hello, Ada!") and the computer said "Hello, Ada!" Ada was amazed. She asked, "How did it do that?" Her brother said, "This is Python โ a language you can use to talk to computers."
Ada wanted to learn more. She started with simple commands, then learned about variables and loops. She wrote a program that asked for her name and said "Hello" back. She was so proud! Soon, she was writing small games and solving math problems with code. Ada discovered that programming is like giving instructions to a very fast, very smart friend. And now, you can learn too!
Definition: Programming is giving instructions to a computer to make it do what you want. These instructions are written in a programming language.
Why it's important: Programming lets you create games, websites, apps, and solve problems. It is like having a superpower!
Simple explanation: Programming is like writing a recipe for a robot โ you tell it exactly what to do, step by step.
Real-life example: A weather app uses programming to show you the forecast.
School example: A student writes code to calculate the average of test scores.
Home example: A parent programs a smart light to turn on at sunset.
Nigerian example: A Lagos startup uses programming to build a delivery app.
Illustration:
+--------------------------------------------------+
| PROGRAMMING = GIVING INSTRUCTIONS TO COMPUTER |
| +----------------------------------------------+ |
| | CODE: print("Hello, World!") | |
| | COMPUTER OUTPUT: Hello, World! | |
| +----------------------------------------------+ |
+--------------------------------------------------+
Mini summary: Programming is writing instructions for computers to follow.
Definition: Python is a programming language that is easy to read and write. It is one of the most popular languages in the world.
Why it's important: Python is used in web development, data science, artificial intelligence, and more. It is a great first language to learn.
Simple explanation: Python is like a friendly language that computers understand, and it's very beginner-friendly.
Real-life example: YouTube and Instagram use Python!
School example: Many schools teach Python as the first programming language.
Home example: You can use Python to automate tasks on your computer.
Nigerian example: Nigerian developers use Python to build web apps and data tools.
Illustration:
+--------------------------------------------------+ | PYTHON IS... | | +----------------------------------------------+ | | | โ Easy to read | | | | โ Fun to write | | | | โ Very powerful | | | | โ Used by big companies | | | | โ Beginner-friendly | | | +----------------------------------------------+ | +--------------------------------------------------+
Mini summary: Python is a popular, easy-to-learn programming language.
Definition: Setting up Python means installing it on your computer so you can write and run Python programs.
Why it's important: You need Python installed to start coding.
Simple explanation: It's like installing a game before you can play it.
Real-life example: A developer installs Python on their laptop.
School example: A student installs Python on a school computer.
Home example: A parent installs Python for their child to learn coding.
Nigerian example: A Nigerian tech student installs Python for a project.
Illustration โ Installation Steps:
1. Go to python.org 2. Click "Download Python" 3. Run the installer 4. Check "Add Python to PATH" 5. Click "Install" 6. Verify by typing: python --version in the terminal
Mini summary: Install Python from python.org to start coding.
Definition: "Hello, World!" is the traditional first program you write in any programming language.
Why it's important: It verifies that everything is set up correctly and introduces you to the basic structure of a program.
Simple explanation: It's like saying "hello" to the computer to make sure it's listening.
Real-life example: Every programmer starts with Hello, World!
School example: A student writes their first Hello, World! program.
Home example: A parent helps their child write their first code.
Nigerian example: A coding beginner in Lagos writes Hello, World!
Illustration โ Code:
print("Hello, World!")
Mini summary: "Hello, World!" is the first program every coder writes.
Definition: A variable is like a box where you can store information. You give it a name and put a value inside.
Why it's important: Variables let you save data and use it later.
Simple explanation: A variable is like a labelled jar โ you put something in and you can take it out later.
Real-life example: name = "Chidi" stores the name "Chidi" in the variable called name.
School example: score = 85 stores the number 85 in the variable score.
Home example: age = 10 stores your age.
Nigerian example: city = "Lagos" stores "Lagos" in the variable city.
Illustration โ Code:
name = "Ada" age = 10 print(name) print(age)
Mini summary: Variables store information for later use.
Definition: Data types tell Python what kind of data a variable holds. The most common are integers (whole numbers), floats (decimal numbers), and strings (text).
Why it's important: Different data types are used differently โ you can do math with numbers, but not with text.
Simple explanation: Data types are like different kinds of toys โ you play with each one differently.
Real-life example: age = 10 (integer) vs name = "Ada" (string).
School example: score = 90 (integer) and subject = "Maths" (string).
Home example: temperature = 28 (integer) and weather = "sunny" (string).
Nigerian example: price = 5000 (integer) and currency = "Naira" (string).
Illustration โ Code:
age = 10 # This is an integer (whole number) price = 2500.50 # This is a float (decimal number) name = "Ada" # This is a string (text) city = "Lagos" # This is a string
Mini summary: Integers are whole numbers, floats are decimals, and strings are text.
Definition: User input lets you ask the user to type something, and your program can use that information.
Why it's important: It makes your program interactive!
Simple explanation: It's like asking a friend a question and using their answer.
Real-life example: A program asks for your name and greets you.
School example: A quiz program asks for the user's answer.
Home example: A recipe program asks how many people you are cooking for.
Nigerian example: A bank app asks for your PIN.
Illustration โ Code:
name = input("What is your name? ")
print("Hello, " + name + "!")
Mini summary: input() lets you ask the user for information.
Definition: Conditional statements let your program make decisions. if checks a condition, and else runs if the condition is false.
Why it's important: They let your program respond differently to different situations.
Simple explanation: It's like saying "If it's raining, take an umbrella; otherwise, wear sunglasses."
Real-life example: If a user enters the correct password, let them in; otherwise, say "Wrong password!"
School example: If a test score is above 50, print "Pass"; otherwise, print "Fail".
Home example: If it's cold, wear a jacket; otherwise, wear a t-shirt.
Nigerian example: If the price is above โฆ10,000, print "Expensive"; otherwise, print "Cheap".
Illustration โ Code:
age = int(input("How old are you? "))
if age >= 18:
print("You are an adult.")
else:
print("You are a child.")
Mini summary: if and else help your program make decisions.
Definition: A while loop repeats a block of code as long as a condition is true.
Why it's important: It lets you repeat tasks without writing the same code over and over.
Simple explanation: It's like a song that repeats until you tell it to stop.
Real-life example: A game continues as long as the player has lives left.
School example: A program asks for a password until the correct one is entered.
Home example: A timer that counts down until it reaches zero.
Nigerian example: A POS machine asks for your PIN until it's correct.
Illustration โ Code:
count = 0
while count < 5:
print("Count is: " + str(count))
count = count + 1
Mini summary: while loops repeat code as long as a condition is true.
Definition: A for loop repeats code a set number of times โ like going through a list.
Why it's important: It's used when you know how many times you want to repeat.
Simple explanation: It's like counting from 1 to 10.
Real-life example: A program prints each item in a shopping list.
School example: A program adds up numbers from 1 to 100.
Home example: A program prints the days of the week.
Nigerian example: A program lists all the states in Nigeria.
Illustration โ Code:
for number in range(1, 6):
print(number)
Mini summary: for loops repeat code a specific number of times.
Definition: A list is a collection of items. You can store multiple values in one variable.
Why it's important: Lists help you organise and manage multiple pieces of data.
Simple explanation: A list is like a basket with many fruits โ you can put lots of things in one basket.
Real-life example: fruits = ["Mango", "Orange", "Banana"]
School example: scores = [85, 90, 78, 92]
Home example: shopping = ["Milk", "Bread", "Eggs"]
Nigerian example: states = ["Lagos", "Abuja", "Kano"]
Illustration โ Code:
fruits = ["Mango", "Orange", "Banana"] print(fruits[0]) # Prints "Mango" print(fruits[1]) # Prints "Orange"
Mini summary: Lists store multiple items in one variable.
Definition: A function is a block of code that you can reuse. You define it once and call it whenever you need it.
Why it's important: Functions help you organise your code and avoid repetition.
Simple explanation: A function is like a recipe โ you write it once and can use it many times.
Real-life example: A function that calculates the area of a rectangle.
School example: A function that greets a user by name.
Home example: A function that converts temperature from Celsius to Fahrenheit.
Nigerian example: A function that converts Naira to Dollars.
Illustration โ Code:
def greet(name):
print("Hello, " + name + "!")
greet("Ada") # Prints: Hello, Ada!
greet("Chidi") # Prints: Hello, Chidi!
Mini summary: Functions are reusable code blocks.
Definition: Comments are notes in your code that Python ignores. They help you (and others) understand what your code does.
Why it's important: Comments make your code easier to read and understand.
Simple explanation: Comments are like sticky notes you leave for yourself.
Real-life example: # This line prints a greeting
School example: # Calculate the average score
Home example: # Convert temperature
Nigerian example: # This function calculates tax
Illustration โ Code:
# This is a comment
print("Hello, World!") # This prints a message
Mini summary: Comments are notes to explain your code.
Definition: Debugging is the process of finding and fixing errors in your code.
Why it's important: Every programmer makes mistakes โ debugging helps you fix them.
Simple explanation: Debugging is like being a detective and finding clues to solve a mystery.
Real-life example: A programmer fixes a typo in their code.
School example: A student fixes a syntax error in their program.
Home example: A parent finds a missing colon in their code.
Nigerian example: A developer fixes a bug in a banking app.
Illustration โ Common Errors:
# Syntax Error: Missing colon
if age >= 18
print("Adult") # Error! Missing colon after 18
# Name Error: Variable not defined
print(score) # Error! score is not defined
# Type Error: Wrong data type
print("Your age is " + age) # Error! age is an integer, not a string
Mini summary: Debugging is finding and fixing errors.
In this module, we learned:
input().if/else) to make decisions.while and for) to repeat code.You are now ready to continue your Python journey!
How to write and run a Python program:
.py extension (e.g., hello.py).python filename.py and press Enter.Start with simple examples and gradually increase complexity. Encourage students to type code themselves, not just copy. Use pair programming โ let students work together. Celebrate small successes. Use Nigerian examples to make learning relatable. Emphasise that errors are a natural part of learning.
Help your child set up Python. Sit with them as they write their first programs. Ask questions like "What do you think this code does?" and "What happens if you change this number?" Encourage curiosity and experimentation. Celebrate their progress and don't worry about mistakes โ they are learning!
input() gets user input.if/else makes decisions.: after if, else, while, and for.= for comparison instead of ==.age, name).+-------------+ +-------------+ +-------------+ +-------------+ | GO TO | --> | DOWNLOAD | --> | RUN | --> | TEST WITH | | PYTHON.ORG | | INSTALLER | | INSTALLER | | "python --version" | +-------------+ +-------------+ +-------------+ +-------------+
| Data Type | What It Is | Example |
|---|---|---|
| Integer | Whole number | 10, 25, 100 |
| Float | Decimal number | 3.14, 2.5, 0.99 |
| String | Text | "Hello", "Ada", "Lagos" |
| Boolean | True/False | True, False |
| List | Collection of items | [1, 2, 3] |
| Loop Type | When to Use | Example |
|---|---|---|
| while | When you don't know how many times | while count < 5: |
| for | When you know how many times | for i in range(5): |
| Statement | When it Runs | Example |
|---|---|---|
| if | When condition is true | if age >= 18: |
| else | When condition is false | else: |
| elif | When first condition is false and another is true | elif age >= 13: |
+------------------------------------------------------------------+ | Lesson 1: What is Programming? | | Lesson 2: What is Python? | | Lesson 3: Setting Up Python | | Lesson 4: Your First Program โ Hello, World! | | Lesson 5: Variables โ Storing Information | | Lesson 6: Data Types โ Numbers and Text | | Lesson 7: User Input โ Asking Questions | | Lesson 8: Conditional Statements โ Making Decisions (if, else) | | Lesson 9: Loops โ Repeating Code (while loop) | | Lesson 10: Loops โ Repeating Code (for loop) | | Lesson 11: Lists โ Storing Many Items | | Lesson 12: Functions โ Reusable Code Blocks | | Lesson 13: Comments โ Explaining Your Code | | Lesson 14: Debugging โ Fixing Errors | | Lesson 15: Review | +------------------------------------------------------------------+
In this first module, we have taken our first steps into the world of Python programming. We learned what programming is and why Python is a great language to start with. We set up Python on our computers and wrote our first "Hello, World!" program. We learned about variables and how they store data. We explored different data types โ integers, floats, and strings. We discovered how to get user input with input() and how to make decisions with if/else statements. We learned about loops โ while and for โ to repeat code. We also learned about lists to store many items, functions to reuse code, comments to explain our code, and debugging to fix errors.
Remember, learning to code is like learning a new language โ it takes practice. Every programmer started where you are now. Keep coding, keep exploring, and have fun! You are now ready to move on to Module Two, where we will learn even more exciting things about Python.
if/else do?_____ gets user input. (input())_____ makes decisions. (if)input() asks the user for information. (True)if makes decisions. (True)input() do?if do?| Term | Definition |
|---|---|
| Python | A) Stores multiple items |
| Variable | B) Reusable block of code |
| List | C) Programming language |
| Function | D) Container for data |
| Comment | E) Note in the code |
Answers: Python-C, Variable-D, List-A, Function-B, Comment-E
if/else do?Scenario 1: You want to write a program that asks the user for their name and age, then prints a message saying "Hello, [name]! You are [age] years old."
Task: Write the code to do this.
Answer:
name = input("What is your name? ")
age = input("How old are you? ")
print("Hello, " + name + "! You are " + age + " years old.")
Scenario 2: You want to write a program that checks if a number is even or odd.
Task: Write the code to do this.
Answer:
number = int(input("Enter a number: "))
if number % 2 == 0:
print(number, "is even.")
else:
print(number, "is odd.")
In groups of three, write a program that asks each group member for their name and favourite food. Store the names and foods in lists. Then, print a message like "Ada likes Jollof Rice." Share your program with the class.
Write a program that asks the user for a number and prints the multiplication table for that number (from 1 to 10).
Build a simple "Quiz Game" program. The program should:
Write a program that acts as a simple calculator. It should:
Write a program that stores the names and scores of 5 students. Then, calculate and print the average score, the highest score, and the lowest score. Also, print the name of the student with the highest score.
Fill-in-the-blank: 1. Programming, 2. Python, 3. variable, 4. integer, 5. float, 6. string, 7. input(), 8. if, 9. while, 10. list
True/False: 1T, 2T, 3F, 4F, 5F, 6T, 7T, 8F, 9T, 10T
Multiple Choice: 1B, 2A, 3A, 4C, 5A, 6A, 7A, 8A, 9A, 10A, 11A, 12A, 13A, 14A, 15A
Matching: Python-C, Variable-D, List-A, Function-B, Comment-E
if/else statements make decisions.while and for) repeat code.In Module Two, we will build on what you have learned. You will explore more advanced topics like:
try/except.Keep practicing and exploring. You are on your way to becoming a Python expert!
๐ Congratulations! You have completed Module One: Welcome to Python Programming ๐
You are now ready for Module Two โ Advanced Python Concepts!