[or [or {{in the first line of the preceding exampleboth operands ( and are true ( are nonzero)so python always stops and returns the one on the left--it determines the result because true or anything is always true in the other two teststhe left operand is false (an empty object)so python simply evaluates and returns the object on the right--which may happen to have either true or false value when tested python and operations also stop as soon as the result is knownhoweverin this case python evaluates the operands from left to right and stops if the left operand is false object because it determines the result--false and anything is always false and and ( [and {[ and [[return left operand if false elsereturn right operand (true or falsehereboth operands are true in the first lineso python evaluates both sides and returns the object on the right in the second testthe left operand is false ([])so python stops and returns it as the test result in the last testthe left side is true ( )so python evaluates and returns the object on the right--which happens to be false [the end result of all this is the same as in and most other languages--you get value that is logically true or false if tested in an if or while according to the normal definitions of or and and howeverin python booleans return either the left or the right objectnot simple integer flag this behavior of and and or may seem esoteric at first glancebut see this sidebar "why you will carebooleanson page for examples of how it is sometimes used to advantage in coding by python programmers the next section also shows common way to leverage this behaviorand its more mnemonic replacement in recent versions of python the if/else ternary expression one common role for the prior section' boolean operators is to code an expression that runs the same as an if statement consider the following statementwhich sets to either or zbased on the truth value of xif xa elsea if tests and syntax rules