16
Lesson 16 of 20 · Variables
Variables — Part 5
Store, update, use in loops. This is part 5 of 20.
What you'll learn
You will learn that variables store values like labeled boxes, and you can read and update them.
Steps
- 1A variable is like a labeled box. Here, 'score' is the label and 0 is what's inside. score = 0 means 'put 0 in the box called score'.
- 2print('Score:', score) looks inside the box and shows what's there — it would display 'Score: 0'.
- 3Then score = score + 1 takes the current value (0), adds 1, and puts the result (1) back in the box. Now score holds 1!
- 4Variables let programs remember and update information — like keeping score in a game, tracking lives, or storing a player's name.
Key Terms
- Variable
- A named place to store a value (e.g. score). You can read it and change it.
- Value
- A piece of data, like a number or text. Variables hold values.
- Assign
- To give a variable a value using = (e.g. score = 0).
Python 3
Output
Loading Python... This may take a few seconds.
Your code runs only in your browser. No code is sent to any server. Stay safe and have fun learning!
Ready?
Variables — Part 5
You will learn that variables store values like labeled boxes, and you can read and update them.
Full screen — no distractions
🖨️View in Shop
Checkout complete lesson on Variables for 7th Grade
Get the full Variables track as a printable PDF — all lessons, worksheets, and answer keys.
