&& (logical AND)
k = 0 for y in range(5, 95, 5): k += 1 if y > 45 and k % 2 == 0: # Set color to red for every other line # for all y > 45. stroke(color(255, 0, 0)) else: stroke(0) # Set color to black line(30, y, 80, y)
Compares two expressions and evaluates to True only if both evaluate to True. Returns False if one or both evaluate to False. The following list shows all possible combinations:
True and False # Evaluates False because the second is False False and True # Evaluates False because the first is False True and True # Evaluates True because both are True False and False # Evaluates False because both are False
The "and" operator is short-circuiting; it will not bother to evaluate its second expression of the first is False. That means, in the following example, that DoSomething is never called:
def DoSomething(): print "I did something!" return True x = False if x and DoSomething(): print "This cannot happen."
expression1 and expression2
or (logical OR)|
not (logical NOT)
Updated on Mon Sep 21 15:53:25 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License