← all tracks/Intro to Python

Variables: Giving Things Names

Variables: Giving Things Names 📦

A variable is a labeled box that stores a value so you can use it later. You create one with =:

score = 10

Now the name score remembers the value 10. You can use it in math, print it, or use it inside a bigger expression:

score = 10
score = score + 5
print(score)  # 15

That second line is a special trick worth noticing: score = score + 5 means "take whatever score is right now, add 5, and save that as the new score." This is called reassigning a variable — giving it a brand new value based on its old one. It's one of the most useful patterns in programming!

A few rules for naming variables:

  • Names can have letters, numbers, and underscores — but can't start with a number.
  • We usually write variable names in snake_case (lowercase with underscores), like total_coins.
  • Pick names that describe what they hold — future-you (and Beep!) will thank you.

Variables make your code easier to read and let you build up an answer step by step instead of writing one giant confusing line. Let's practice!

# problems