WhatsApp/Telegram +65 8858 6173 classes@computhink.com.sg

This article is Part 1 of a series explaining the basic concepts of programming that will be taught in the Beginner Computhink for Kids! classes. For enquiries, email us at create@computhink.com.sg


 

One of most basic blocks of computer programming is the “If (this), then (do that)” conditional blocks. Much of the complicated computer processing done in programmes comes down to this simple but very powerful concept underlying computer programming.

You make decisions every day, and when that happens, you basically execute an if-else conditional block inside your head.

 

Example 1: If (this happens), then (do that action)

If (the skies look dark, and it might rain)

Then, you will bring an umbrella out

To expand on the If block further, we might use an If-Else block as had been included in Example 2.

 

Example 2: If (this), then (do that), else (do something else)

If (the skies look dark, and it might rain)

Then, you will bring an umbrella

Else, let’s go to the beach!

Here, you have added another action to take, when the “if” condition did not happen.

Here’s an example of an animation done using the if-else conditional blocks in Scratch:

Learn if-else using Scratch

The visual block code will look something like this and kids simply need to drag and drop these blocks to create this animation:

Scratch Visual Block Code

Let’s listen to Bill explaining the If-Else conditional here:

It is fun and interesting, isn’t it? And kids get excited when they realise they can easily create animations and games using this simple yet powerful conditionals! The if-else conditionals is one of the seven basic concepts of programming that we teach in our Beginner Computhink for Kids! classes.

Next up in Part 2, we will explain how you get the computer to do something over and over again without it ever being bored or tired (i.e. Loops!).