# Week Three: Conditionals and Cool Stuff

·

This workshop is part of series incolaboration with Friends of Refugees with the aim of empowering youth to code and have fun!

## Hello!! Welcome Back!

Lovely to see you again!! We will be doing more fun coding things! You don't need the laptop quite yet so keep it closed!

## What we are aiming for this class

• Learn what is a if/else statement

• Playing fun if statement game!

• Another fun colour revision game!

• Make our own if statements!

• Coding our monster!!

If we have time:

We will learn about greater and less than.

But first! Let's play a game!!

## What is an if statement???

Sounds fancy but we use conditional statement all the time when we speak.

An if statement is a sentence that has some condition that has an outcome if it is/isn't met.

A little confusing. Here are some examples:

• If its raining I will bring an umbrella on my walk

• If I am hungry I will eat snacks

• If I am not late I will catch the early train

Can you think of any if sentences???

## True or False

When using if statements we have conditions that are true or false. In programming something is either true or false, real life is a bit more complicated!

For example: If I am hungry I will eat snacks

You might remember what a variable was from the first class (its just a name for something). If I were to code this I would have a variable called `hungry` which would be either true or false. Varaibles that are true/false are called boolean variables. It might look something like this.

`if(hungry === true){snacks++}`

In class today we are just going to be using one premade variable to keep things simple.

## What else??

An extra wrinkle. In programming we use if and we use else. Else is used when you have an outcome that you want to happen when a condition isn't met. It's not always needed and we won't focus on else too much.

Here is an example:

If I have apples I will make a pie else I will bake cookies

It sounds a bit weird because noone talks like that. Let's play Simon Say's If Then Else, it will make more sense!

## Simon Says If Then Else

Everyone stand up. Listen closely to the IF statements the helper says and follow allong!!

## RGB Revision Game!

Woohoo Simon Says was fun and theres no stopping the games!

## Let's Write our Own If Statements!

We are ready to code our if statements! Exciting.

## Coding our Monster

You guys did great work coding your monster last week. Let's add the new stuff we learnt to make our monster interactive. Using the if/else statement try to make your monster change when you click the mouse.

Some ideas:

• Monster changes colour when you click

• Monsters eye get big when you click

• Moster gets bigger when you click