What Is a Conditional?
So far your programs always run the same blocks in the same order, no matter what. But real programs can make decisions. A conditional is a block that checks a question and only runs if the answer is yes.
You already use conditionals every day:
- 👣 If it is raining, bring an umbrella.
- 🌿 If the light is red, stop. If green, go.
- 🐱 If the cat meows, feed it.
💡
Key Idea
A conditional says: "IF this is true, THEN do this." An if/else says: "IF true, do A; OTHERWISE do B."
True and False
Every condition evaluates to either true or false — there is no in-between. "Score > 5" is either true or false right now. "It is raining" is true or false right now.
When the condition is true, the IF block runs. When it is false, the IF block is skipped — or the ELSE block runs instead.
📌
Conditionals + Loops
A conditional by itself checks once. Inside a loop, it checks every iteration — making the program react automatically to changing conditions!