0% found this document useful (0 votes)
13 views

Variables

Variables and it's types

Uploaded by

Bashair Nasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Variables

Variables and it's types

Uploaded by

Bashair Nasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Magic Boxes Called Variables

Computer Science for Kids

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:

⋆ Your lunchbox has your name on it

⋆ Your cubby at school has your name

⋆ Each drawer in your room might hold different things

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:

→ scoreBox = 0 (Game starts)

→ scoreBox = 10 (You got points!)

→ scoreBox = 25 (You got more points!)

Activity: Watch It Change!


Help Mario track his coins through the game:

⋆ marioCoins = 0 (Start)

⋆ marioCoins = (Collected 5 coins)

⋆ marioCoins = (Collected 3 more coins)

⋆ marioCoins = (Lost 2 coins)

2
3 3. Different Types of Variables
Variables can hold different kinds of things:

Number Box Text Box

42 ”Hello”
Yes/No Box

true
Examples:
• Number variables: age, score, temperature

• Text variables: name, favoriteColor, bestFriend

• Yes/No variables: isHappy, canPlay, hasWon

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

⋆ They can store different types of information

⋆ Their values can change

⋆ Always give them clear names that make sense

4
Bonus Fun!
Draw a picture of your favorite variable as a labeled box and what it
contains!

You might also like