← Back to course

If-Then: Making Decisions

The trick

Programs get smart when they can make decisions, using if-then (called a conditional). The pattern is: IF something is true, THEN do this — otherwise (ELSE) do that. For example: IF score is above 100, THEN show "You win!" ELSE show "Try again." The computer checks the condition and picks a path. This is how a game knows you've won, how an app knows your password is correct, and how a thermostat decides to turn on the heat. Combine sequence, loops, and if-then and you can build almost anything.

Worked examples

🧩 Unplugged activity: Write three if-then rules for a pretend robot pet: "IF I clap, THEN sit." "IF it is dark, THEN sleep. ELSE play." Test them by acting out different situations.

Practice

0 / 0 0.0s