Variables
Variables
What is a Variable?
A variable is like a magical box where you can store things and give it
a special name! Just like you have a toy box for your toys, variables
are boxes in the computer where we keep information.
1 1. Understanding Variables
Think of variables like labeled boxes:
scoreBox nameBox
100 ”Alex”
ageBox
10
1
isPlayingBox levelBox
true 5
colorBox
”blue”
2 2. Variables Can Change!
Just like you can put different things in your backpack each day, variables
can change their values!
coinsBox
collect spend
50 −−−→ 75 −−−→ 60
Example:
⋆ marioCoins = 0 (Start)
2
3 3. Different Types of Variables
Variables can hold different kinds of things:
42 ”Hello”
Yes/No Box
true
Examples:
• Number variables: age, score, temperature
Fun Exercises!
Exercise 1: Create Your Own Variables
Fill in the blanks to create variables about yourself:
• myGrade =
• myTeacherName =
• numberOfSiblings =
• favoriteSport =
• canSwim =
3
Exercise 2: Story Time with Variables!
Help complete this story by filling in the variables:
⋆ heroName =
⋆ heroAge =
⋆ heroPower =
⋆ isHeroStrong =
The story reads: ”Once there was a hero named (heroName). They
were (heroAge) years old. Their special power was (heroPower). Was
the hero strong? (isHeroStrong)!”
Remember!
⋆ Variables are like labeled boxes
4
Bonus Fun!
Draw a picture of your favorite variable as a labeled box and what it
contains!