0
Operation precedence
Please help me understand this.. I thought Python would treat + signs as an OR and * as an AND operator.. but I'm not getting the same results: Why ? if 1 + 1 * 3 == 6: print("True") else: print("False") The result of this is FALSE but once I change it to OR (instead of +) I get TRUE printed out. if 1 or 1 * 3 == 6: print("True") else: print("False")
1 Resposta
+ 3
1 is True, that's why the rest of the statement won't be checked. No matter what comes after "1 or", it will always evaluate to True