Logic Lab: Conditionals

Mastering the "If-Then" logic that powers the digital world.

1. The Core Concept

At the heart of every computer program is the ability to make decisions. We call these Conditions. Just like you decide to wear a coat IF it is cold outside, computers evaluate data to choose a path.

The If Statement

The simplest check. Runs code only if a condition is true.

if (isRaining) {
  takeUmbrella();
}

The If-Else

A fork in the road. Do one thing if true, another if false.

if (passwordCorrect) {
  login();
} else {
  showError();
}

Else-If Chain

Checking multiple possibilities in a specific order.

if (score > 90) { grade = 'A' }
else if (score > 80) { grade = 'B' }
else { grade = 'C' }

2. Quick Check

Test your knowledge before moving to the lab.

1. Which statement covers the "backup plan" if all previous conditions are False?

3. Activity: The Smart Thermostat

Mission: You are programming a smart home controller. The system generates a random temperature. You must set the logic rules to ensure the house stays comfortable.

Logic Editor

Simulation Output

System Ready
Waiting for logic...
> System initialized...
> Waiting for code upload...