Python Tutorial #4: Booleans

Published on: 15 Sept. 2024

Category: python tutorial


Boolean values in Python are a data type that can only take two values: True or False. These values are often used to control conditions in logical expressions, loops, and control structures such as if, while, and for statements.

Characteristics of Booleans in Python


# boolean values
x = True
y = False

print( 5 > 3 ) # True
print(2 == 5 ) # False

if x:
    print("x value is True")
else:
    print("x value is False")
                                        

Boolean values are fundamental for controlling the flow of programs.