Follow an If/Else Rule
Choose one branch of an algorithm by checking a stated condition.
Supplied materials
- Paper and a pencil, or say your answers aloud.
Learn the idea
A condition is a question with a true or false answer. An if/else rule chooses one action when the condition is true and another when it is false. Follow the stated rule rather than choosing the action you prefer.
Our paper sorting rule is: “If a card has a star, put it in box A; otherwise, put it in box B.” Check the card before choosing a box. In this rule, the color of the card does not matter.
- Draw a card with a star and a card with a circle.
- Write the condition: Does the card have a star?
- Put the star card in your drawn box A and the circle card in box B.
- Try the check with a different shape.
See the method in action
A green card with a star goes to A. A green card with no star goes to B. Being green does not change the rule.
Check your reasoning
Your answer is temporary and is not saved to an account. Download your current answer before leaving or reloading. Written work on paper or in another app stays in your own file.
See the answer and explanation
box B because it has no star
The condition asks whether the card has a star. This card has only a triangle, so the condition is false and the otherwise branch sends it to B.
Take it further
Change the rule to “If the card has a triangle, use A; otherwise use B.” The same triangle card now goes to A because the condition changed.
Nothing here is saved to an account or sent to a teacher. The answer download includes your current choice and any checked feedback.
Check the subject sources
These LifeStarter passages, scenarios and exercises are authored for this Academy with AI assistance and review. External resources keep their publishers’ terms. A grade label suggests a starting level; it does not establish alignment with your school’s complete requirements.