This lesson will introduce students to the basics of decision-making in code using If/Then/Else logic. This is how we program computers to make decisions in coding.
We use this logic everyday without thinking about it! Think about how we decide what to wear in the morning. We use a simple decision-making process:
If
it is a school day, then
we wear our uniform.
Else
, we wear our casual clothes.
By using if
, else-if
, and else
, students will learn to give a program multiple options, guiding it to a specific outcome depending on the conditions.
Start by getting brains warmed up with a quick decision-making round.
Explain to your students that we make hundreds of small decisions every day using simple if/then logic.
Tell them you're going to read a sentence, and their job is to complete it with a logical action on their mini-whiteboards or in their copybooks.
Read one sentence at a time, give them 30–45 seconds to write, and then ask for a couple of clear responses before moving on. Encourage them to write specific and safe actions.
If it’s raining at break, then ________.
If your pencil breaks, then ________.
If you spill water, then ________.
If the crossing light is red, then ________.
If you finish your work, then ________.
After the quick-fire round, bring the class back together. Point out that the first part of the sentence—the if part—is the condition. It sets up a situation. The second part—the then part—is the action, or what you do in response to that situation.
Explain that in coding, this if/then logic is the most basic building block of every program. It's how computers make quick, sensible choices. In our daily lives, using clear conditions and predictable actions helps keep our routines safe, fair, and easy to follow.
Now that your students are comfortable with if/then logic, it's time to give our programs a default option.
Explain that when we make a decision, we often have a backup plan for when our first choice isn't an option. In coding, this backup plan is called else. It's a command that means "otherwise," telling the program what to do if the if condition is not true.
To illustrate, show your students this simple if/then/else scenario, like a Break Time Planner:
If it's raining, then we'll stay indoors for yard time. Else (or otherwise), we'll use the playground.
Point out that this gives the program a clear instruction for both possible outcomes, ensuring it never gets stuck.
Now that we understand if/then/else statements, let's learn how to draw our decisions.
Explain to your students that a flowchart is like a map for a program. It helps us see where a process begins, what steps we take, and how a choice can change our path.
Now, have a look at the "Break time Planner" we did in the previous step, and show your students how it would look as a flowchart. You can draw it on the board as you explain each step (or use our image below).
Point out that you start at the top, and the decision changes which arrow, or path, you follow. It helps us see the entire process at a glance and makes it easy to spot any mistakes in our logic.