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

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

Log in to reply
 

});