Account
Categories

OR Logical Operator (or)


Definition:

The OR operator uses or.

It checks two conditions and returns either true or false.

The operands can be either variables or values.

So, it is called the OR operator.

Syntax:

if condition1 or condition2:
    # Following the example matches the one condition is true, then the output will print.

Example:

x = 15
y = 14

if x > 20 or y > 5:
    print("At least one condition is true")

Output:

Note: If one condition is true, the output will print.

Exercise

Use the OR Logical Operator to check if a = 10 is greater than 20 or b = 5 is greater than 0, then print "At least one condition is true".