when you perform boolean operation on non-boolean types empty string (''), 0, emprty containers like empty list, empty tuple, etc. are evaluated as false, everything else is evaluated as True.
When you perform or operation, python will stop evaluating expression once it has reached True
When you perform and operation python will stop immediately once it reach False.
When perform and/or Python returns the sub-expression that was evaluated last before evaluating the expression as a whole.
3 < (10 or 2) on first steps is evaluated to
3 < 10 and now this is evaluated to True
in the second case
3 < (2 or 10)
becomes
3 < 2
and is finally evaluated False
When you perform or operation, python will stop evaluating expression once it has reached True
When you perform and operation python will stop immediately once it reach False.
When perform and/or Python returns the sub-expression that was evaluated last before evaluating the expression as a whole.
>>> True or [] True >>> [] and True # note it will not return False, but [] [] >>> (10 or 2) and False False >>> (10 or 2) or False 10 >>> 10 and 2 2 >>> 2 and 10 10 >>> 10 or 2 10 >>> 2 or 10 2in your case, because of parenthesis and operator precedence it will first evaluate the expression in the parenthesis on the right-hand side. That is (10 or 2) in the first case and (2 or 10) in the second. In the former case it will be evaluated to True and the result will be the first expression evaluated to True - 10, so
3 < (10 or 2) on first steps is evaluated to
3 < 10 and now this is evaluated to True
in the second case
3 < (2 or 10)
becomes
3 < 2
and is finally evaluated False
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs