๐ WAYPOINT LESSON
Variables & Assignment
โญ beginnerโณ 10 min read๐ Lesson 5 of 169
Names that remember: assignment, naming, reassignment.
A variable is a name that refers to a value. Assignment uses = (read it as
"becomes", not "equals"):
age = 21
name = "Minh"
Variables let programs remember. Once assigned, use the name anywhere below:
price = 5
quantity = 3
total = price * quantity # 15
print(total)
Naming rules (and taste)
- Names may contain letters, digits, and underscores:
user_name,score2. - They cannot start with a digit or contain spaces.
- Case matters:
totalandTotalare different names. - Style: use
snake_caseโ lowercase with underscores. Future-you reads names as documentation.
Reassignment
Variables point to values; pointing can change:
score = 10
score = score + 5 # now 15
Python evaluates the right side first (10 + 5), then re-points the name.
โก Now practice
Ready to CodeVariable DrillsAssign, combine, and update variables.
3 challenges ยท ยท ~30 min