Boolean CS Thinking Example 4
Follow the full solution, then compare it with the other examples linked below.
Example 4
mediumA theme park ride requires: age ≥ 12 AND height ≥ 140. A child is age 13 and height 135. Evaluate the full Boolean expression step by step. Can they ride?
Solution
- 1 Step 1: Evaluate age ≥ 12 → 13 ≥ 12 → TRUE.
- 2 Step 2: Evaluate height ≥ 140 → 135 ≥ 140 → FALSE.
- 3 Step 3: Combine with AND → TRUE AND FALSE → FALSE.
Answer
FALSE — the child cannot ride. AND requires both conditions to be TRUE; one FALSE makes the whole expression FALSE.
Real-world eligibility rules often combine multiple conditions with AND (all must be met) or OR (at least one must be met). Evaluating each sub-expression separately, then combining, avoids mistakes.
About Boolean
A data type representing a logical value that can only be true or false—nothing else. Booleans are produced by comparison operators (==, <, >, !=) and consumed by control structures (if-statements, while-loops) to make decisions.
Learn more about Boolean →More Boolean Examples
Example 1 easy
Evaluate each expression when x = 7: (a) x > 5, (b) x == 10, (c) x != 7, (d) x >= 7.
Example 2 mediumA variable `isLoggedIn` is a boolean. Write pseudocode that outputs 'Welcome back' if logged in, or
Example 3 easyWhat is the value of each: (a) NOT TRUE, (b) (5 < 3) OR (10 > 8), (c) (4 == 4) AND (3 > 5)?