The short-circuit logic python

Copyright: Shallow @ Copyright original article may not be reproduced without permission https://blog.csdn.net/xili2532/article/details/80464208

Logic programming language used
if a and b: # if a is false, the determination is skipped b, results directly to false
IF a or b: # If a is true, then the judgment skip b, direct true
That is: if A is equal to 100, B is equal to 200. The A and B == 200; A or B == 100,
A and B: if A is False, the A and B returns False, if A is True, the A and B return to B.

A or B: If A is False, the A or B returns B, if A is True, the A or B A return.

A and B == 200, A 100 (a True), so the result of logic "AND" operation depends on the B (what is it returned B).

A or B == 100, A 100 (a True), so the logical "OR" result of the operation depends on A, because A is True, and so no matter who is the logical "or" operation result is True i.e., A .

Guess you like

Origin blog.csdn.net/xili2532/article/details/80464208