Boolean CS Thinking Example 3
Follow the full solution, then compare it with the other examples linked below.
Example 3
easyWhat is the value of each: (a) NOT TRUE, (b) (5 < 3) OR (10 > 8), (c) (4 == 4) AND (3 > 5)?
Solution
- 1 Step 1: (a) NOT TRUE = FALSE. (b) FALSE OR TRUE = TRUE.
- 2 Step 2: (c) TRUE AND FALSE = FALSE.
Answer
(a) FALSE, (b) TRUE, (c) FALSE.
Combining comparison operators with logical operators (AND, OR, NOT) builds complex conditions used in program control flow.
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 4 mediumA theme park ride requires: age β₯ 12 AND height β₯ 140. A child is age 13 and height 135. Evaluate th