If/Then Choice Builder
Programs make decisions all the time. Build your own IF/THEN/ELSE rules, toggle conditions, and watch what happens. Every app you use runs thousands of these checks every second.
Watch how IF/THEN/ELSE works!
IFit is raining
THEN🧥 wear a raincoat← active
ELSE👕 wear a t-shirt
😊
🧥Wear a raincoat
The condition "It is raining" is TRUE - wear a raincoat!
Computer Logic Reference
What is a Condition?
A condition is a question that has exactly two answers: true or false. There is no "maybe."
- "It is raining" is either true or false right now
- "The light is red" is true or false
- Conditions let computers make choices automatically
- Programmers call true/false values booleans
IF/THEN/ELSE
Every IF/THEN/ELSE rule has two paths:
- IF the condition is true, follow the THEN path
- ELSE (if the condition is false), follow the ELSE path
- Only one path runs - never both
- This is called a conditional statement
Boolean Logic
Conditions use boolean values named after mathematician George Boole. A boolean is always exactly one of two values:
- true (yes, on, 1)
- false (no, off, 0)
- Computers represent true as 1 and false as 0 in memory
- All computer decisions come down to 1s and 0s
Real Computer Decisions
Every app on your phone or computer runs IF/THEN checks constantly. Some examples:
- IF battery < 20% THEN show low battery warning
- IF password is correct THEN log in ELSE show error
- IF it is nighttime THEN use dark mode ELSE use light mode
- Games use thousands of these checks every second to respond to players
Related Content
Related Tools
Binary, Decimal & Hex Converter
Convert between binary, decimal, hexadecimal, and octal. Bit-level visualization, ASCII lookup, and step-by-step conversion methods.
Truth Table Generator
Enter Boolean expressions with AND, OR, NOT, XOR, and IMPLIES to generate complete truth tables. Detects tautologies and contradictions.
Sorting Algorithm Visualizer
Watch bubble, selection, insertion, merge, and quick sort in action with color-coded bars for comparisons, swaps, and sorted elements.
Big-O Complexity Visualizer
Compare O(1), O(log n), O(n), O(n log n), O(n^2), O(n^3), and O(2^n) on an interactive graph. See operation counts at any input size.
Related Labs
If/Then Choice Lab
Build IF/THEN/ELSE decision rules and test them with real-world scenarios. Discover how computers use conditional logic to make decisions. Grades 3-5.
Selection & Iteration Lab
Trace through if/else, for, while, and nested loops step by step. Evaluate Boolean expressions with short-circuit logic. Explore common patterns like accumulator, FizzBuzz, and multiplication tables
Loops, Debugging & Animation Lab
Compare flat programs to loop-based ones, fix buggy programs, and create event-driven sprite animations
Coding Mazes & Sequencing Lab
Write step-by-step programs to navigate a robot through mazes, trace execution, and debug broken sequences