For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Do Operators use Lazy evaluation?

  • does the AND operator evaluate its second operand if the first one evaluates to false?

    similarly for OR and IF are the operators lazy?

  • AND refers to both the condition holding true/false and or refers to one of the conditions holding true/false.
    for example:

    val1 = 5.0
    val2 = 6.0
    if val1 > 2.0 and val2 < 10.0:

    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')

Log in to reply