Challenge - 5 Problems
Boolean Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Boolean expressions with logical operators
What is the output of this Python code snippet?
Python
a = True b = False print(a and not b)
Attempts:
2 left
💡 Hint
Remember that 'not' reverses the Boolean value.
✗ Incorrect
Variable 'a' is True, 'b' is False, so 'not b' is True. 'True and True' results in True.
❓ Predict Output
intermediate2:00remaining
Boolean conversion of different values
What will be the output of this code?
Python
print(bool(0), bool(1), bool([]), bool([0]))
Attempts:
2 left
💡 Hint
Zero and empty containers are False; non-empty containers and non-zero numbers are True.
✗ Incorrect
0 and empty list [] are False; 1 and list with one element [0] are True.
❓ Predict Output
advanced2:00remaining
Boolean evaluation in conditional expressions
What is the output of this code?
Python
x = 5 result = 'Yes' if x > 3 and x < 10 else 'No' print(result)
Attempts:
2 left
💡 Hint
Check if x is between 3 and 10.
✗ Incorrect
x is 5, which is greater than 3 and less than 10, so the condition is True and 'Yes' is printed.
❓ Predict Output
advanced2:00remaining
Boolean logic with mixed operators
What will this code print?
Python
a = False b = True c = False print(a or b and c)
Attempts:
2 left
💡 Hint
Remember operator precedence: 'and' before 'or'.
✗ Incorrect
'b and c' is 'True and False' which is False; then 'a or False' is 'False or False' which is False.
🧠 Conceptual
expert2:00remaining
Understanding Boolean identity and equality
Which statement about Python Boolean values is correct?
Attempts:
2 left
💡 Hint
Check the difference between '==' and 'is' in Python.
✗ Incorrect
'==' checks value equality, so True == 1 is True; 'is' checks identity, so True is 1 is False because they are different objects.