Guidelines

Which values are always considered False?

Certain values like 0 and empty strings ("") are automatically considered False in conditional statements.

By using these, you can control the flow of a program by making the result of an arithmetic operation 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 (integer 0, float 0.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.")
Mission
0 / 1

An empty list [] is evaluated as False in an if statement.

O
X

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result