Variables

#coding

Variables are an important part of learning how to code! Variables in coding and variables in math are actually quite similar. This video looks at coding variable types, including strings, numbers, and booleans. This fun variables song for kids will answer the question ‘What are variables?’ while encouraging you to dance and sing along at the same time!

Lyrics

 

Variables

They have a name

And variables 

Have values that can change

Variables

A part of coding foundation

Because variables 

Store important information!

 

So, just like this box can hold this ring

A variable is something that can hold another thing

Like a name, or a date, or a high score

Or a place, your favorite food, and so much more!

You might be confused, have no fear

We can try a little example here

Say this bucket is a variable, we’ll give it a name

So whatever is in the bucket we will call bucketThing!

 

bucketThing is a frog 

bucketThing is a bear

bucketThing is a pizza

bucketThing is underwear!

 

Now variables can have a type, are you listening?

They can have a type, and here’s the main three

The variable types, when you are talking to machines

are strings, numbers, and booleans!

A string is not a number it’s actually made of letters

Like your name or the words “I really like sweaters”

A string is text, you know characters and letters

Just like the sentence “A bird has feathers.”

Here’s a string variable about what day it is

We will name this variable dayOfTheWeek

 

dayOfTheWeek is Monday

dayOfTheWeek is Tuesday

dayOfTheWeek is Wednesday

dayOfTheWeek is Thursday!

 

Variables

They have a name

And variables 

Have values that can change

Variables

A part of coding foundation

Because variables 

Store important information!

 

So string variables, what are they good for?

When there are words and text to store

What if you have numbers, like numbers and math?

A number variable is up to the task

Numbers are numbers and nothing more

No letters, or pictures, just a number, like a score!

Numbers are numbers and nothing more

No letters, or pictures, just a number, like a score!

Here’s a number variable to remember the score

we will name this variable myPointScore

 

myPointScore is 2

myPointScore is 4

myPointScore is 8

myPointScore is 1,000,000!

 

So number variables, what are they good for?

When there are numbers and numbers to store

But there’s a simpler one, it can be one of two things

It’s called boolean variable, it’s not a number or a string

Boolean, there’s a funny name

It just means true or false, no in-betweens!

Boolean, it can only be two things

Either true or false! No in-betweens!

Here’s a boolean variable to check if you’re asleep

we will name this variable areYouAsleep

 

areYouAsleep is true!

areYouAsleep is false!

areYouAsleep is true!

areYouAsleep is false!

 

Variables

They have a name

And variables 

Have values that can change

Variables

A part of coding foundation

Because variables 

Store important information!