If/Then Choice Lab

Build IF/THEN/ELSE decision rules, test them with real-world scenarios, and discover how computers use conditional logic to make billions of decisions every second.

Guided Experiment: If/Then Decision Rules Investigation

Before you start, predict: what happens in a computer program when the IF condition is false? Write your prediction.

Write your hypothesis in the Lab Report panel, then click Next.

Choose a scenario to explore:

Decision Rule: Weather Outfit

IFIs it raining?
THENWear a raincoat
ELSEWear a t-shirt
Apps check the weather forecast and suggest clothing

Test the Condition

Is it raining?

0 / 500
0 / 500
0 / 500

Controls

Reference Guide

What Is a Condition?

A condition is a question that a computer can answer with just two options: TRUE or FALSE.

Every IF statement checks a condition. The computer reads it and immediately decides which path to follow.

  • TRUE conditions. The THEN branch runs.
  • FALSE conditions. The ELSE branch runs.
Key idea: the computer never skips the check. It always evaluates the condition before doing anything else.

IF/THEN/ELSE Structure

Every decision rule follows the same three-part structure:

  • IF block (blue). States the condition to check.
  • THEN block (green). What happens when the condition is TRUE.
  • ELSE block (amber). What happens when the condition is FALSE.

Only one of THEN or ELSE runs each time. Never both.

Conditions in Real Life

Computers use IF/THEN/ELSE rules constantly. Here are some examples you encounter every day:

  • Your phone locks after 30 seconds of no activity.
  • A game adds a point only IF you hit the target.
  • A crosswalk light turns white IF the button is pressed.
  • A thermostat turns on the heat IF the room gets too cold.
Real programs can contain millions of IF/THEN/ELSE rules working together at the same time.

Nested Decisions

Sometimes a THEN or ELSE branch contains another IF/THEN/ELSE rule inside it. This is called nesting.

Example:

  • IF it is raining THEN put on a raincoat.
  • IF it is also cold THEN add a warm hat.
  • ELSE just wear the raincoat.

Nested rules let computers handle more complex situations by checking multiple conditions in order.