Relational and Boolean Operators

Relational Operators

greater_than = 7 > 4               # True (7 is greater than 4)
less_than = 8 < 10                 # True (8 is less than 10)
greater_than_equal_to = 7 >= 7     # True (7 is equal to 7)
less_than_equal_to = 7 <= 7        # True (7 is equal to 7)

print(greater_than)
print(less_than)
print(greater_than_equal_to)
print(less_than_equal_to)

Output:


Boolean AND Operator (and)

Output:


Boolean OR Operator (or)

Output:


Not Operator (not)

Output:


βœ… Summary:

  • Relational operators compare values (>, <, >=, <=).

  • Boolean operators combine expressions:

    • and: True if both sides are True.

    • or: True if at least one side is True.

    • not: Reverses the Boolean value.

True Table Cheatsheet

Last updated