In this lesson, you'll teach students about rule-based systems and conditional logic, two fundamental concepts in computer science.
A rule-based system is a program that uses a set of rules to make decisions. They are the "brains" behind many smart devices, like a traffic light that changes colour based on a timer, or a vending machine that dispenses a snack only after money is inserted.
At the heart of every rule is a conditional statement. This is a basic conditional that sets a rule for a computer to follow. For example, if a user presses the "pizza" button, then dispense a slice of pizza. You can add an "else" to create a backup plan: if the pizza button is pressed, then dispense pizza, else do nothing. This is the core logic that tells a computer what to do under a specific set of circumstances.
This lesson will help students see that these abstract concepts are already at work in the world around them.
Ask students to think about something in their lives that runs on rules. This could be a game, a sport, or a machine. What are their rules?
Guide the discussion with examples like a traffic light or a vending machine. Explain that these are simple systems that follow a set of rules to make a decision. A traffic light, for instance, follows the rule, "If it's been red for 60 seconds, then turn green."
Explain that today, students will become system designers. They'll create their own "smart" machine by writing its rules. These rules are called conditionals because they allow a machine to make decisions based on specific conditions.
Write the basic structures on the board. Explain that these are the building blocks for every conditional rule they will create.
IF [something is true] THEN [do something]
IF [something is true] THEN [do this] ELSE [do something else]
Point out that conditions can be combined to make our rules more specific. Write these examples on the board as well.
Briefly explain the difference between the words AND and OR when we use them in our rules.
AND: This is a strict rule. Both conditions must be true for the machine to follow the instruction. If it is cold but not raining, the robot will do nothing.
OR: This is a flexible rule. At least one of the conditions must be true for the machine to follow the instruction. If you are hungry, the robot will send you to the kitchen, even if it is not yet lunchtime.
Begin the lesson by asking your students to think about all the different ways they've heard the word smart. Guide them beyond a "smart person" to examples in technology. They might mention a smartphone, a smart TV, or a smart speaker.
Explain that in technology, "smart" doesn't mean a device can think like a human. Instead, a smart system is a machine that has been programmed with a set of rules to make decisions and respond to different situations.
Today, they will be the system designers who write the rules for a smart system.
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.