Python and and or are short-circuit operators, so yes: in your example, if "q" is false, the interpreter will not evaluate "r".
edit - after a little thought, it occurs to me that it is important to note that Python and and or work sort of like Javascript && and || . They do not produce a logical result. In other words, operands ("q" and "r") are sorted as "internally" rather than boolean when evaluating, but this is just to see how execution should be performed. Thus, if "q" and "r" are non-empty strings, the result of q and r is the string value "r", not boolean true . However, when used in the specified context (the if ), the if itself will bring the result to a logical one in order to make its own solution to the control flow, so the answer for this example is still βyesβ :-)
source share