LESSON 3
Variables
Learning objective: Store data in variables in Python.
Understand
Variables hold values you can reuse.
In Python you create a variable simply by assigning to it — no keyword needed. Names should be lowercase with underscores. You can reassign a variable at any time.
Analogy: A variable is a labelled box you can fill and refill.
See It in Action
Assigning and using variables:
name = "Sam"
age = 20
print(name, age)How it works:
name and age are created by assignment, then printed together.Try It Yourself
- Create a variable for your favourite number.
- Print it.
- Reassign it and print again.
Quick Quiz
How do you create a variable in Python?
Challenge
Store three facts about yourself in variables and print them.
Success condition: Your program prints values from three variables.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →