Hey there! Today we are going to explore variables, which are like magical, labeled boxes in coding that hold information for us.
In coding, a variable is a named container that stores information. We can use variables to keep track of things like game scores, player names, or the speed of a character.

We can change, or modify, the data inside our variable whenever we want. When we put a new value into the variable, the old value is replaced and forgotten.
Let's analyze how changing a variable affects a program. Imagine a game where your score starts at 0, and you earn 5 points for every gold coin you grab. By changing the score variable, the game screen updates to show your new total instantly!
We want to write a program that tracks a player's health. The player starts with 3 hearts. When they touch a spike, they lose 1 heart. Let's explain how to use a variable to modify this data step-by-step.
- First, we create a variable named 'hearts' and set its starting value to 3.
- Next, we write a rule in our code: 'If player touches spike, subtract 1 from hearts.'
- Then, we run the game. The player touches a spike!
- Finally, the program modifies the variable. It calculates 3 minus 1, and stores the new value of 2 inside the 'hearts' variable.
