Name

or (logical OR)

Examples
k = 0
for y in range(5, 95, 5):
    k += 1    
    if y > 45 or k % 2 == 0:
        # Set color to red for every other line when y <= 45
        # and all y > 45.
        stroke(color(255, 0, 0))
    else:
        stroke(0)    # Set color to black
    line(30, y, 80, y)
Description

Compares two expressions and returns True if one or both evaluate to True. Returns False only if both expressions are False. The following list shows all possible combinations:

True or False   # Evaluates True because the first is True
False or True   # Evaluates True because the second is True
True or True    # Evaluates True because both are True
False or False  # Evaluates False because both are False

The "or" operator is short-circuiting; it will not bother to evaluate its second expression of the first is True. That means, in the following example, that DoSomething is never called:

def DoSomething():
    print "You will never see this message!"
    return True

x = True
if x or DoSomething():
    print "This always happens."
Syntax
expression1 or expression2
Parameters
expression1any valid expression
expression2any valid expression
Related && (logical AND)
not (logical NOT)
if

Updated on Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.