Recall & Review
beginner
What does it mean when a value is truthy in Python?
A truthy value is any value that Python treats as True when used in a condition, like in an
if statement. For example, non-zero numbers and non-empty strings are truthy.Click to reveal answer
beginner
What is a falsy value in Python?
A falsy value is any value that Python treats as False in a condition. Examples include
0, '' (empty string), [] (empty list), None, and False itself.Click to reveal answer
beginner
Which of these values is falsy in Python? <br> A) 1 <br> B) '' <br> C) 'False' <br> D) [1, 2]
The correct answer is B) ''. An empty string is falsy. The others are truthy because 1 is non-zero, 'False' is a non-empty string, and [1, 2] is a non-empty list.
Click to reveal answer
intermediate
How does Python decide if a value is truthy or falsy in an
if statement?Python uses the built-in
bool() function internally to check the truthiness of a value. If bool(value) returns True, the value is truthy; if it returns False, the value is falsy.Click to reveal answer
beginner
Give two examples of truthy and two examples of falsy values in Python.
Truthy examples:
42 (non-zero number), 'hello' (non-empty string).<br>Falsy examples: 0 (zero), [] (empty list).Click to reveal answer
Which of the following is considered falsy in Python?
✗ Incorrect
An empty string ('') is falsy. 'False' is a non-empty string, so it is truthy.
What does Python use internally to check if a value is truthy or falsy?
✗ Incorrect
Python uses the bool() function to determine the truthiness of a value.
Which of these values is truthy?
✗ Incorrect
Non-empty lists like [1, 2, 3] are truthy.
Is the number -5 truthy or falsy in Python?
✗ Incorrect
Any non-zero number, including negative numbers, is truthy.
Which of these is NOT a falsy value in Python?
✗ Incorrect
A string with a space (' ') is non-empty, so it is truthy.
Explain what truthy and falsy values are in Python and give examples of each.
Think about how Python treats values in conditions like if statements.
You got /4 concepts.
How does Python determine if a value is truthy or falsy when used in a condition?
Consider what happens inside an if statement.
You got /3 concepts.