Learning outcomes
- Write a first script
- Understand variables and data types
Core concepts
Lessons
Module goal
Learner writes their first real script and understands what variables and data types actually are — not just how to spell them, but why they exist and how Python treats them.
Lesson 1 of 4 · lecture
What is a variable?
Step 1 of 3
A variable is a named container that stores a piece of information so you can use it later. Think of a labelled box: write “age” on a box, put 25 inside, and any time you say age, Python looks in that box.
age = 25
name = "Kenneth"Common confusion
The = sign does not mean “equals” as in maths — it means “assign this value to this name”. Read age = 25 as “age is now set to 25”.
Why variables matter: without them every program would hardcode values everywhere, and changing one thing would mean hunting through the entire script. Variables make code flexible, reusable and readable.
Guided labs
Build your personal info script
- 1.Create a new file called basics.py
- 2.Create four variables: name (string), age (integer), city (string), favourite language (string)
- 3.Add a comment above each variable explaining what it stores
- 4.Use print() to display a full sentence combining all four
name = "Kenneth"
age = 30
city = "Accra"
language = "Python"
# Print a formatted introduction using all variables
print("My name is " + name + ", I am " + str(age) + " years old, I live in " + city + ", and I'm learning " + language + ".")
# Cleaner, modern alternative — an f-string
print(f"My name is {name}, I am {age} years old, I live in {city}, and I'm learning {language}.")Teaching point
f-strings are preferred in professional Python: cleaner, more readable, and they handle type conversion automatically so you never need str() inside them.
Success criteria
Running the script prints a complete, correctly formatted sentence with no errors.
Knowledge Check
Question 1 of 6
What does the = sign do in Python when creating a variable?
What you read
- What a variable is (a container for information)
- Naming rules (no spaces, start with a letter, avoid reserved words)
- Why data types matter (numbers vs. text behave differently)
What you understand
Key takeaways
- — Variables store and reuse information
- — Different data types behave differently in operations
- — Comments make code readable for future reference
Hands-on lab
Lab tasks
- 1.Create variables for name, age, favorite language
- 2.Print a formatted sentence using them
Knowledge check
- Identify data types
- Spot naming errors
- Explain a variable's purpose
Write your answers in your own notes before moving on — explaining a concept in your own words is the fastest way to find the gaps.