Python Foundations
Variables
A variable is a name that points at a value. You create one with =, reading it as "set this name to this value":
city = "Lagos"
year = 2026You can reassign a variable later. The newest value wins, and the old one is forgotten:
score = 10
score = 25
print(score) # 25A common move is to build a new value out of the current one. Reading the right side first, then storing the result back into the same name:
score = 10
score = score + 5
print(score) # 15Naming rules
- Use lowercase words joined by underscores:
first_name,total_cost. - Start with a letter or underscore, never a digit.
- Pick clear names.
days_leftbeatsdevery time.
Your turn
Set score = 10. Then reassign score to itself plus 5 so it becomes 15. Finally print the value of score.
Lesson complete. Nice work.
Code · runs in your browser
Output
This lesson is locked
Lessons open one at a time. Finish the previous lesson to unlock this one.