2019-10-02: The community is currently in read-only mode
Do Operators use Lazy evaluation?
greg nwosu last edited by
does the AND operator evaluate its second operand if the first one evaluates to false?
similarly for OR and IF are the operators lazy?
Robin Dhillon last edited by
AND refers to both the condition holding true/false and or refers to one of the conditions holding true/false.
val1 = 5.0 val2 = 6.0 if val1 > 2.0 and val2 < 10.0: print(True)
this would fail if val2 was infact greater than 10.0
for the 'OR' case:
val1 = 5.0 val2 = 6.0 if val1 > 2.0 or val2 == 10.0: print('only condition one is true')