What is a variable?
Section 7: Variables and randomnessLesson 7.1 · ⏱ 7 min
A variable is a box with a name that keeps a number that can change. The best-known example: the score in games.


🖥️ What happens on the stage?
The score starts at zero, every click on Robo adds one, and the number shows on the stage.
📌 Note
We always start with set at the flag, so every new game starts from zero.
📌 Another example: a step counter
The variable steps starts at 0, and every press of the arrow adds 1. join sticks the word to the number.



✍️ Practise
Make a variable called score, and make the two scripts.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
The variable lives starts at 3, every click on Robo takes 1 away, and Robo says how many are left.
👀 Show the solution🙈 Hide the solution



Medium
Count from 1 to 10 with a variable count inside repeat, and Robo says the number.
👀 Show the solution🙈 Hide the solution


Hard
The variable s starts at 50. In every round make Robo's size = s, then add 20 to s. What is Robo's size at the end?
👀 Show the solution🙈 Hide the solution



