0% found this document useful (0 votes)
13 views14 pages

Python Week2 Lesson Plan

Uploaded by

o.odebunmi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views14 pages

Python Week2 Lesson Plan

Uploaded by

o.odebunmi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🐍 PYTHON FOR BEGINNERS

WEEK 2 — Variables & Data Types


Class Duration: 1 Hour 30 Minutes | Age Group: ~10 Years Old
Theme: Storing Information

🎯 Learning Objectives
By the end of this class, every student will be able to:
• Understand what a variable is and why we use them
• Create variables to store text (strings) and numbers (integers and floats)
• Explain the difference between int, float, and str data types
• Use the type() function to check what kind of data is stored in a variable
• Update a variable by changing its value

🕐 Class Schedule at a Glance


Follow this timetable to keep the lesson on track. Every segment builds on the last!

Time Activity Notes for Teacher


0:00–0:10 🔁 Recap & Warm-Up Quick review of Week 1 — what is print()? Then
introduce today's topic with the 'box' analogy.
0:10–0:25 📦 What is a Variable? Explain variables using boxes. Live demo in Thonny.
Students follow along.
0:25–0:45 The Three Data Types Teach str, int, and float one at a time. Use real-life
comparisons for each.
0:45–0:55 🔍 type() + Changing Show type() in action. Demonstrate updating variables.
Values Short practice.
0:55–1:05 Printing with Variables Combine variables with text in print(). Try comma
method together.
1:05–1:25 📝 Classwork Exercises Students work on exercises 9–13. Teacher circulates
and encourages.
1:25–1:30 🏠 Homework & Wrap-Up Assign homework, recap key vocabulary, celebrate the
lesson!
🔁 SECTION 1 — Recap & Warm-Up (10 minutes)
Quick Review of Week 1
Start by getting brains warmed up! Ask the class these quick questions out loud and take 2–3 answers
each:

❓ Warm-Up Questions — Ask the Class!


1. What is a program? (Answer: a list of step-by-step instructions for the computer)
2. What does print() do? (Answer: it displays text on the screen)
3. What do we call text inside quotation marks in Python? (Answer: a string)
4. What happens when Python finds a mistake? (Answer: it shows an error message to help you!)

Introducing Today's Topic


After the warm-up, use this script to introduce variables:

🎬 Teacher Script: The Magic Box


"Last week, we learned how to make Python say things using print().
But what if we want Python to REMEMBER things? Like your name, your score in a game,
or how many coins you have collected?

That's where VARIABLES come in. A variable is like a labelled box.


You put something inside the box, give the box a name, and Python remembers it for you.

Today we are going to learn how to create these boxes, what kinds of things we can put in them,
and how to look inside them whenever we want."

📦 SECTION 2 — What is a Variable? (15 minutes)


The Labelled Box Analogy
This analogy is the heart of the lesson. Take your time with it!

📦 Imagine This...
Picture a row of boxes on a shelf in a storeroom.

Each box has a LABEL written on the outside — like 'player_name' or 'score'.
Each box has something INSIDE it — like the word 'Alex' or the number 100.

A variable in Python is exactly like this:


• The LABEL = the variable's name
• The CONTENTS = the variable's value
At any point, you can open a box and look inside.
You can also take out what's inside and put something new in — the box stays,
only the contents change!

Your First Variables — Live Demo in Thonny


Ask students to open Thonny and follow along, typing each line as you do:
# Creating variables — putting things in boxes
player_name = "Alex"
player_score = 0
player_level = 1

# Displaying variables — looking inside the boxes


print(player_name)
print(player_score)
print(player_level)

Run it! Ask: 'What do you see in the Shell?' Then ask: 'Which line made each thing appear?'

💡 The = Sign in Python is NOT 'equals'!


In maths class, = means 'these two things are the same'.
In Python, = means something completely different!

player_name = "Alex"

This means: 'Take the text Alex and PUT IT IN the box called player_name.'
We call this ASSIGNING a value to a variable.

Think of = as an arrow pointing LEFT: player_name ← "Alex"


The value on the right goes INTO the box named on the left.

Explore: Make Your Own Variables


Give students 3–4 minutes to make their own variables. Prompt them:

Try It Yourself!
Create these variables in Thonny:

my_name = "your name here"


my_age = your age here (no quotes!)
my_city = "your city here"
my_score = 0
Then use print() to display each one.
What happens in the Shell? Does it match what you put in the box?

SECTION 3 — The Three Main Data Types (20 minutes)


Before diving into each type, show students the big picture using this comparison table:

Type What It Holds Example


str Text — words, sentences, names, name = "Alex"
anything with characters

int Whole numbers — no decimal point, no age = 10


quotes

float Decimal numbers — has a decimal point, height = 1.42


no quotes

Data Type 1: String (str) — Text 📝

📝 What is a String?
A STRING is any piece of text. Letters, words, sentences, even numbers written as text!

The golden rule: strings ALWAYS go inside quotation marks.


You can use double quotes: "Hello"
Or single quotes: 'Hello'
Both work exactly the same way in Python.

Real-life examples of things that would be strings:


• Your name (Jordan)
• A city name (Lagos, London, Tokyo)
• A message ('Good morning!')
• A colour ('electric blue')

Type and run this code together:


# String examples
first_name = "Jordan"
last_name = 'Smith'
favourite_colour = "electric blue"
favourite_animal = "red panda"

print(first_name)
print(last_name)
print(favourite_colour)
print(favourite_animal)
⚠️ Common Mistake: Numbers as Strings
What is the difference between age = 10 and age = "10" ?

age = 10 → This is an INTEGER. Python sees the number ten.


age = "10" → This is a STRING. Python sees the characters 1 and 0.

If you tried to do maths with "10", Python would get confused!


So: numbers you want to calculate with — NO quotes.
Numbers used just as text (like a phone number) — use quotes.

Data Type 2: Integer (int) — Whole Numbers 🔢

🔢 What is an Integer?
An INTEGER is a whole number — no decimal point, and definitely NO quotes.

Think about things you count:


• Your age (10, 11, 12...)
• A game score (0, 100, 1500...)
• Number of players (1, 2, 4...)
• Points collected (0, 5, 20...)

These are all perfect examples of integers!

Can be positive (10, 500), zero (0), or negative (-5, -100).

Type and run this code together:


# Integer examples
age = 10
num_siblings = 2
high_score = 1500
number_of_pets = 0

print(age)
print(high_score)

Ask the class: 'Can you think of three more things in real life that would be integers?'

Data Type 3: Float (float) — Decimal Numbers 📏

📏 What is a Float?
A FLOAT is a number WITH a decimal point.
"Float" is short for "floating point number" — the decimal point can float around
to different positions (like 1.5, 14.75, or 0.001).

Think about things you measure rather than count:


• Your height in cm (142.5)
• Your weight in kg (35.8)
• Pocket money with pence/cents (£4.75)
• A temperature (36.6°C)

If you see a decimal point — it's a float!

Type and run this code together:


# Float examples
height_cm = 142.5
weight_kg = 35.8
pocket_money = 4.75

print(height_cm)
print(pocket_money)

🤔 Quick Check — What Type Would These Be?


Ask students to call out the type for each of these. Discuss any disagreements!

"Hello" → ____
42 → ____
3.14 → ____
"100" → ____ (trick question! It has quotes, so...)
0 → ____
99.99 → ____
"London" → ____

Answers: str, int, float, str, int, float, str


🔍 SECTION 4 — type() Function & Changing Variables (10
minutes)
Checking Types with type()
Explain: 'Python has a built-in tool that lets you ask: what kind of thing is inside this box?'

🔍 How type() Works


The type() function looks inside a variable and tells you what kind of data it holds.
You wrap type() around a variable name — just like print() — and Python reports back.

It will say one of three things:


<class 'str'> → it's a string (text)
<class 'int'> → it's an integer (whole number)
<class 'float'> → it's a float (decimal number)

The word 'class' just means 'category' — don't worry about it for now!

Type and run this code together:


name = "Alex"
age = 10
height = 1.42

print(type(name)) # Output: <class 'str'>


print(type(age)) # Output: <class 'int'>
print(type(height)) # Output: <class 'float'>

Ask students to guess the output BEFORE running. Then run and check!

Changing Variable Values


Here is one of the most powerful ideas about variables: you can change them!

🔄 Variables Can Change!


Remember the labelled box? You can always reach into the box and swap out what's inside.
The label (name) stays the same — only the contents change.

This is perfect for things like:


• A player's score going up during a game
• A character's health going down when they get hit
• A timer counting down
• A shopping total adding up as you buy items

Type and run this code together, step by step:


score = 0
print("Score at start:", score)

score = 100
print("Score after winning:", score)

score = 250
print("Final score:", score)

Watch the Shell output carefully. Ask: 'What happened to the number 0? And then 100?'

💡 The Key Idea


When you write: score = 100

Python does NOT add 100 to whatever was there before.


It REPLACES whatever was there with 100. The old value is gone!

This is like erasing what's in the box and writing something new.
Old value disappears. New value takes its place.

SECTION 5 — Printing Variables with Text (10 minutes)


Combining Variables and Text
So far we've just printed the variable alone. But in a real program, we usually want to print a sentence
that includes the variable. Here's how!

💬 The Comma Method


Inside print(), you can have multiple items separated by commas.
Python puts a space between each item automatically.

print("My name is", name)

Python reads this as: display the text 'My name is', then a space, then whatever is in name.

You can mix as many text pieces and variables as you like — just keep separating with commas!

Type and run this example together:


name = "Taylor"
age = 10
city = "Lagos"

print("My name is", name)


print("I am", age, "years old")
print("I live in", city)
print("Nice to meet you,", name, "from", city)

Ask students to predict each line of output before running it. Then run and compare!

🌟 Teacher Tip: Let Students Experiment!


Give students 3 minutes to play freely. Suggestions:
• Change name to their own name — does it update everywhere?
• Can they print their name 5 times with one print() statement?
• What happens if they forget a comma?

Allow errors to happen — that's part of learning!

📏 SECTION 6 — Naming Rules for Variables (brief — 2 minutes)


Cover these rules quickly before classwork. One minute is enough — students will learn them naturally
through practice:

✅ ALLOWED ❌ NOT ALLOWED


player_name (letters + underscore) player name (no spaces!)
score2 (number at the end) 2score (number at the start!)
myAge (camelCase is ok) my-age (no hyphens!)
first_name_and_last_name (long is class (reserved Python word!)
fine)
x (short is ok for quick things) my name! (no symbols!)

💡 Best Practice: Use Descriptive Names!


Python won't stop you calling a variable x or a.
But when you look at your code later, which is easier to understand?

x = 10 → what is x? No idea!
player_health = 10 → Instantly clear!

Good variable names make your code read almost like English.
Professional programmers spend time thinking about good names — it really matters!
📝 SECTION 7 — Classwork Exercises (20 minutes)
Students work independently or in pairs. Walk around and encourage. Celebrate creative ideas — there
are no wrong answers for the content of the variables, only for the syntax!

Exercise 9 — My Profile Card 🪪


Create a program that builds a profile card for yourself. Make a variable for each of the following, then
print them all in a nicely formatted way:
• Your full name (string)
• Your age (integer)
• Your favourite subject at school (string)
• Your favourite sport (string)
• Number of siblings (integer)
• Your height in cm (float)

Example output:
===== MY PROFILE CARD =====
Name: Jordan Smith
Age: 10
Favourite Subject: Science
Favourite Sport: Football
Siblings: 2
Height: 142.5 cm

💡 Tip for Students


To get the neat header, use: print('===== MY PROFILE CARD =====')
Then use the comma method to combine label text with each variable.

Exercise 10 — The Changing Box 🔄


This exercise shows how variables update over time. Create a variable called message, change it three
times, and print it after each change:
1. Create message and set it to the text 'Hello'. Print it.
2. Change message to 'Goodbye'. Print it again.
3. Change message to any phrase you like. Print it one more time.
4. Observe: the variable name stayed the same, but the content changed each time!

Bonus question: What happens to the old value when you reassign a variable? (It disappears — Python
only remembers the most recent value!)
Exercise 11 — Type Detective 🔍
Create exactly 9 variables: 3 strings, 3 integers, and 3 floats. They can be about anything you like!
Then use type() to print the type of each one.

Example:
favourite_food = "jollof rice"
num_goals_scored = 5
temperature = 37.2

print(type(favourite_food))
print(type(num_goals_scored))
print(type(temperature))

Try to make the variables about interesting things — your hobbies, your room, your favourite things!

Exercise 12 — Pet Profile 🐾


Design a profile for a real or imaginary pet. Create variables for:
• Pet's name (string)
• Species or animal type (string)
• Age in years (integer)
• Weight in kg (float)
• A fun fact about the pet (string)

Then print a nicely formatted pet profile. Example:


===== PET PROFILE =====
Name: Biscuit
Species: Red Panda
Age: 3 years
Weight: 4.5 kg
Fun Fact: Red pandas use their bushy tails as blankets in winter!

Exercise 13 — CHALLENGE: Video Game Character Card 🎮


Create variables for an imaginary video game character's stats, then display them as a character card
in the Shell. Include all of these:
• name — the character's name (string)
• health — hit points, e.g. 100 (integer)
• attack — attack power (integer)
• defence — defence rating (integer)
• speed — speed value (integer)
• level — current level (integer)
• weapon — their weapon name (string)
• special_power — their special ability (string)
Example output:
==============================
⚔️ CHARACTER CARD ⚔️
==============================
Name: Shadow Fox
Level: 7
Health: 120 HP
Attack: 85
Defence: 60
Speed: 95
Weapon: Twin Daggers
Special Power: Vanish into Shadows
==============================

🌟 Challenge Extension
Can you print TWO different characters and compare them?
Try making a hero and a villain — give each one their own set of variables.
(Hint: you'll need different variable names for each character, like hero_name and villain_name)

🏠 SECTION 8 — Homework & Wrap-Up (5 minutes)


Homework Assignments

Homework 14 — Family Profile Program


Create a program with variables for each person in your family. For each family member, store their
name and age in variables, then print a sentence about them.

Example:
mum_name = "Amina"
mum_age = 38
print("My mum is", mum_name, "and she is", mum_age, "years old")

Try to include at least 3 family members!

Homework 15 — Research: Boolean Data Type


Python has a fourth data type we haven't learned yet called a BOOLEAN (bool). Your task:
5. Look up what a boolean is in Python (search: 'Python boolean for beginners')
6. Write 2–3 sentences explaining it in your own words
7. Try a simple example in Thonny and bring your code to class next week

Hint to get you started: a boolean can only have two possible values. What do you think they are?
🎓 Wrap-Up Script for Teacher
With 5 minutes remaining, bring the class together:

"Today you learned something that EVERY programmer uses every single day — variables!
You learned how to create boxes that store information, the three main types of data
(strings, integers, and floats), and how to update a variable as your program runs.

Next week, we are going to make Python do MATHS with our variables — adding, subtracting,
multiplying — and that is when things really start to get exciting!"

Ask: 'Can anyone tell me — without looking — what a variable is?'


Give a round of applause for every attempt! 👏
📋 Quick Reference Card — Week 2
Cut this out and keep it at your desk!

Concept What It Means / Example


Variable A labelled box that stores a value. E.g. score = 10
= (assignment) Puts a value INTO a variable. NOT the same as 'equals' in maths!
str (string) Text in quotes. E.g. name = "Jordan"
int (integer) Whole number, no quotes. E.g. age = 10
float Decimal number, no quotes. E.g. height = 1.42
type() Tells you what data type is in a variable. E.g. print(type(name))
Reassignment Giving a variable a new value. The old value is replaced.
print(x, y, z) Prints multiple items with spaces between them.
snake_case Naming style using underscores: player_name, high_score

🐍 Variables are the building blocks of every program — great work today! 🐍

You might also like