The big ideaAn if-then rule does an action only when its condition is true.
How it works
An if-then rule does an action only when its condition is true.
The if part is the condition. Bo checks it, and it is either true or false.
The then part is the action. It happens only when the condition is true.
When the if is false, the then is skipped and nothing happens, which is fine.
The two parts of a rule.
Example 1: No check
Mira says water the flowers, but never says when.
Bo waters them even in the rain, because his rule does not ask him to look.
The flowers get soggy.
Example 2: A dry morning
The new rule is if the soil is dry, then water the flowers.
Bo pokes a finger in the soil, and it is dry and crumbly.
The condition is true, so Bo does the then part.
The condition is on line 1, the action on line 2.
Example 3: A damp afternoon
After a drizzle Bo checks again, and the soil is damp.
The condition is false, so Bo skips the action.
He simply walks on by.
Example 4: Mira's umbrella
Mira's rule is if it rains, open the umbrella.
The day is clear, so the condition is false.
The umbrella stays shut and the then part is skipped.
Words to know
condition
A yes or no question that is either true or false.
action
What Bo does when the condition is true.
if-then rule
A rule with an if part and a then part.
Watch out
A rule needs a condition and an action. Without a check, Bo acts every time.
The condition goes after if, and the action goes after then. Do not swap them.
A false condition is not an error. The action is just skipped.
A condition can be true one day and false the next.
Try it
The soil is damp. Does Bo water the flowers?
In if the bell rings, then line up, which part is the condition?
In if it rains, then open the umbrella, which part is the action?
When does the then part run?
Can a condition be true one day and false the next?
Answers: 1. No · 2. The bell rings · 3. Open the umbrella · 4. Only when the condition is true · 5. Yes
Try at homeWith a grown-up, make three if-then rules for your home, like: if the bell rings, then I open the door. Say which part is the if and which is the then. No screen needed.
For grown-upsDo the Mission: make three if-then rules for your home together, like if the bell rings, then I open the door. Say which part is the if and which is the then. No screen needed.
Open these notes on screenScan the code, or go to tutorpip.com.