Boolean Examples: 46 Problems with Answers
Worked examples of Boolean to try before you open each solution, then practice problems with answers.
Worked Examples
Example 1
easyShow solution
Answer
First step
Full solution
- 2. Step 2: Evaluate (a) TRUE and (b) FALSE.
- 3. Step 3: Evaluate (c) FALSE and (d) TRUE.
Example 2
mediumExample 3
mediumExample 4
mediumExample 5
mediumExample 6
hardExample 7
hardPractice Problems
Try each one, then open the solution to compare your method.
Example 1
easyExample 2
mediumExample 3
easyExample 4
easyExample 5
easyExample 6
easyExample 7
easyExample 8
easyExample 9
easyExample 10
easyExample 11
mediumExample 12
mediumExample 13
mediumExample 14
mediumExample 15
mediumExample 16
mediumExample 17
mediumExample 18
mediumExample 19
mediumExample 20
challengeExample 21
challengeExample 22
challengeExample 23
easyExample 24
easyExample 25
easyExample 26
easyExample 27
easyExample 28
easyExample 29
mediumExample 30
mediumExample 31
mediumExample 32
mediumExample 33
mediumExample 34
mediumExample 35
mediumExample 36
hardExample 37
hardExample 38
hardExample 39
challengeWhat to focus on
Core idea: Booleans are the language of decisions. Every if-statement evaluates a boolean condition.
Common stuck point: 0, empty string, None/null, and empty lists are often 'falsy' — they act like False in conditions even though they're not boolean.
Ask yourself: Can the value only be yes or no, or is it the result of a comparison that an if or while will read?
Concept recap
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.
A checkbox on a form is a boolean: ticked or empty, with no third state, and anyone can read it later without asking the question again. A comparison like age >= 13 is the person deciding whether to tick it; the if statement is the office that reads the box. The picture stops at Python's truthy values, where 0 or empty text also counts as an empty box.
Read the full lesson on BooleanRelated concepts
Background knowledge
These ideas may be useful before you work through the harder examples.