Today, we're going to learn how to make decisions in code. Just like you make choices every day, a program needs to follow a set of rules to decide what to do. The key to this is if/then logic, where a program says, 'if this happens, then do that.'
To explore this, we’ll become the Lunch Robot! We'll look at fun examples, draw flowcharts, and even act like a robot that decides what to serve for lunch based on a series of rules. Get ready to program your own decisions and make some exciting choices!
Start the lesson by asking your students if they've ever had to make a decision based on something else happening first. You can give a few simple, relatable examples to get them thinking, like:
"If it's sunny, then I can play outside."
"If the bus is late, then I'll walk to school."
"If I finish my homework, then I can watch TV."
Explain that these are called conditional statements. The word conditional simply means that an action depends on a specific condition being true. In coding, we use conditional statements to give a computer a set of rules to follow. The most basic and important of these is the if... then... statement.
Before you introduce the full if/then/else structure, start with the most basic conditional to build a strong foundation. This simple model helps students understand that a program's path depends on whether a single condition is true.
Display this flowchart on the board:

Explain that this shows the most direct way a program makes a decision. It checks a condition, and if it's true, it follows one path. This naturally leads to the next big question for the class: "But what should the program do if it is raining?" This is the perfect moment to introduce the else path.
In coding, when we want to give our robot an instruction for what to do if the condition is false, we use the word else. Think of it like a backup plan! The robot will always have an instruction, no matter what.
Display this new flowchart on the board to show how the else feature gives our program a path for every possible situation.
This is a complete conditional statement, and it ensures our robot will always have an instruction.

You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.