Conditions

#coding

What are conditions? They are things that decide! Learn about conditions in coding with this fun and original Conditions Song & Video. Often called conditionals, or if/then statements, conditions are a fundamental part of learning how to code!

Lyrics

Conditions conditions

We use conditions all the time!

But what are conditions?

They are things that decide!

 

Conditions in coding, well you use them when

You need to make a decision

Usually they have an IF and a THEN

And you can use them again and again!

You use conditions in your life every day

When you think about choices when you work and you play

You use IFs and THENs in your lives every day

Listen up and I willl throw some examples your way

 

IF you are hungry THEN you should eat

IF you are smelly THEN you should wash your feet

IF you finish your homework THEN you can watch TV

And IF you want to learn THEN listen to me!

 

Conditions conditions

We use conditions all the time!

But what are conditions?

They are things that decide!

 

Imagine you are coding a simple game

To shoot a ball into a hoop is the aim

2 points for each ball that goes in

But now this brings up a good question

How is the computer gonna know when

To add 2 points when the ball goes in?

I think it’s time to use a condition

And of course it’s gonna have an IF and a THEN

Let’s go! So points are stored in a variable called theScore

theScore starts at zero but there’s gonna be more

Next, hmmm what are we gonna do?

Set up a true-false variable is what we’ll do

We’ll call this new variable isItIn

It’s set to false when you start the game

But it will change to true if the ball goes in

Now we’ll set up a condition

That will check the value of IsItIn

And if it is true, you know what we’re gonna do?

Then theScore will go up by 2!

 

Aww ya 

You’re doing it

Just remember, a condition uses an IF and THEN to plan the path of a decision!

Ya a condition uses an IF and THEN to plan the path of a decision! 

Ya a condition uses an IF and THEN to plan the path of a decision! 

Ya a condition uses an IF and THEN to plan the path of a decision! 

 

Conditions conditions

We use conditions all the time!

But what are conditions?

They are things that decide!