# and - both must be TrueTrue and True#ans: TrueTrue and False#ans: FalseFalse and True#ans: FalseFalse and False#ans: False
# or - at least one TrueTrue or False#ans: TrueFalse or True#ans: TrueFalse or False#ans: FalseTrue or True#ans: True
# not - inverts booleannot True#ans: Falsenot False#ans: Truenot (5 > 3)#ans: False
# combining with andx = 10x > 5 and x < 15#ans: True#ans: combining with orx < 5 or x > 8#ans: True
# and stops at first FalseFalse and (1/0)#ans: False (no error, doesn't evaluate 1/0)#ans: or stops at first TrueTrue or (1/0)#ans: True (no error)
# what is the result?True and True#ans: True# short circuit evaluation?False and (1/0)#ans: False (no error, doesn't evaluate second part)
# short circuit with or?True or (1/0)#ans: True (no error)# what about this?not False#ans: True
# chaining and/or?True or False and False#ans: True (and has higher precedence)# boolean with comparison?5 > 3 and 10 < 20#ans: True
# tricky: what is this?bool([]) and bool([1])#ans: False# what evaluates?0 or 5#ans: 5 (returns last truthy value)
# and returns?5 and 10#ans: 10 (returns last value if all truthy)# mixed types?"hello" and ""#ans: "" (returns last value or first falsy)
# what about this?not not True#ans: True# De Morgan's law?not (True and False)#ans: Truenot True or not False#ans: True
# order of precedence?True and False or True#ans: True (and first, then or)# empty values?[] or [1, 2]#ans: [1, 2]
Google tag (gtag.js)