Open In App

Python False Keyword

Last Updated : 08 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

False is a boolean value in Python that represents something untrue or a “no” condition. It is one of the two Boolean constants (True and False) and is mostly used in conditions, loops and logical operations.

In Python, False is treated as 0 in mathematical operations and as a falsy value in conditional statements. Let’s look at an example.

Python
if False:
    print("This will never execute")

Since the condition is False, the print statement will not execute.

Let’s look at some examples that involve using False keyword.

Using False in Conditional Statements

Python
x = 10
f = x < 5

if f:
    print("x is less than 5")
else:
    print("x is not less than 5")

Output
x is not less than 5

Explanation: The condition x < 5 evaluates to False, so the else block get executed instead of the if block.

Using False to Initialize Flags.

A flag is a variable used to track a condition in a program. It is usually set to False at first and changed when needed.

Python
f = False   # flag variable
a = [1, 3, 5, 7, 9]

for i in a:
    if a == 5:
        f = True
        break

if f:
    print("Number found!")
else:
    print("Number not found.")

Output
Number not found.

Explanation: flag ‘f’ starts as False and it becomes true only if 5 is found in the list.

Using False as 0 in Arithmetic

Python treats False as 0 in arithmetic operations therefore in some cases it can be used in place of 0.

Python
print(False + 5)  
print(False * 3)  

Output
5
0

Explanation: since False is treated as 0, Fasle + 5 results in 5 and False * 3 results in 0.



Next Article
Article Tags :
Practice Tags :

Similar Reads