Which values are always considered False?
Certain values like 0
and empty strings ("")
are automatically considered False
in conditional statements.
These values can be used to control program flow—for example, when the result of an arithmetic operation is 0
.
Examples of values evaluated as False
a = 2 b = 3 if a - b: print("a - b is not 0.") else: print("a - b is 0.")
What values are always evaluated as False?
-
Numeric
0
(integer0
, float0.0
) -
Empty string
""
-
Empty list
[]
, empty tuple()
, empty dictionary{}
-
None
Using conditionals
When these values are passed to an if statement, the condition is evaluated as False
and the block of code does not execute.
Examples of values evaluated as False
if 0: print("This will not execute.") else: print("0 is evaluated as False.") if "": print("This will not execute.") else: print("An empty string is evaluated as False.")
Quiz
0 / 1
An empty list []
is evaluated as False in an if statement.
True
False
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result