Fundamentals of Python Programming โ Level 1: Your First Steps into Coding
Welcome, young coder! Have you ever wanted to talk to computers and tell them what to do? Python is a programming language that is easy to learn and very powerful. It is used by scientists, game developers, web builders, and even astronauts! This course will take you from absolutely zero knowledge to writing your own Python programs. We will use simple words, fun examples, and lots of practice. By the end of this course, you will be able to write code, solve problems, and create small projects. Let's start your coding adventure!
After completing this course, 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. 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.
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.
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 | | | +----------------------------------------------+ | +--------------------------------------------------+
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 two most common are integers (whole 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) name = "Ada" # This is a string (text) price = 5000 # This is an integer city = "Lagos" # This is a string
Mini summary: Integers are whole numbers; 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 course, we learned:
You are now ready to start your coding journey!
How to write a simple program:
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!
+-------------+ +-------------+ +-------------+ +-------------+ | GO TO | --> | DOWNLOAD | --> | RUN | --> | TEST WITH | | PYTHON.ORG | | INSTALLER | | INSTALLER | | "python --version" | +-------------+ +-------------+ +-------------+ +-------------+
| Data Type | What It Is | Example |
|---|---|---|
| Integer | Whole number | 10, 25, 100 |
| String | Text | "Hello", "Ada" |
| Float | Decimal number | 3.14, 2.5 |
| 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 course, 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, data types, user input, conditional statements, loops, lists, and functions. We also learned about comments and debugging. You now have a solid foundation in Python programming. Remember, the key to learning programming is practice โ keep coding, keep exploring, and have fun!
| 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
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. string, 6. input(), 7. if, 8. while, 9. list, 10. function
True/False: 1T, 2T, 3F, 4F, 5T, 6T, 7F, 8T, 9T, 10F
Multiple Choice: 1B, 2A, 3A, 4A, 5A, 6A, 7A, 8A, 9A, 10A, 11A, 12A, 13A, 14A, 15A
Matching: Python-C, Variable-D, List-A, Function-B, Comment-E
In Level 2, we will build on what you have learned. You will explore more advanced topics like:
Keep practicing and exploring. You are on your way to becoming a Python expert!
๐ Congratulations! You have completed the Fundamentals of Python Programming โ Level 1 course outline! ๐
You are now ready for Level 2 โ Advanced Python Concepts!