Raven writes a list of rules on the whiteboard. Each one starts with if.
"If it has a handle, then tool," Rocket reads. "That one is easy!"
Raven taps the list. "What do you notice? The order of the rules matters."
Nova hovers by the board. "Here is a hint," she says. "Check rule 1 first. Stop at the first match."
An if-then rule has a test and an action.
If the test is true, then the computer does the action.
A list of rules is checked from the top. The first rule that matches wins.
The computer follows the rules exactly. It never changes them by itself.
| Rule | If... | Then... |
|---|---|---|
| 1 | it has a handle | label it tool |
| 2 | it has leaves | label it plant |
| 3 | none of the rules above match | label it rock |
Rules work well when the job is clear.
Rules are easy to read. You can see exactly why the computer chose.
But when there are many tricky cases, the list of rules gets very long.
| Statement | True or false? |
|---|---|
| An if-then rule has a test and an action. | ? |
| The computer checks the rules from the bottom up. | ? |
| You can read a rule to see why the computer chose. | ? |
| The computer changes its rules all by itself. | ? |
You wrote rules like a programmer! Tomorrow the lab tests rules and examples side by side.