0% found this document useful (0 votes)
20 views1 page

Boolean Operators in Python

The document outlines the three main Boolean operations: 'or', 'and', and 'not', detailing their results and evaluation rules. It emphasizes that 'or' and 'and' are short-circuit operators, evaluating the second argument only when necessary. Additionally, it notes the priority of 'not' in relation to non-Boolean operators, affecting how expressions are interpreted.

Uploaded by

fahrimurobbi24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Boolean Operators in Python

The document outlines the three main Boolean operations: 'or', 'and', and 'not', detailing their results and evaluation rules. It emphasizes that 'or' and 'and' are short-circuit operators, evaluating the second argument only when necessary. Additionally, it notes the priority of 'not' in relation to non-Boolean operators, affecting how expressions are interpreted.

Uploaded by

fahrimurobbi24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Boolean Operations — and, or, not

These are the Boolean operations, ordered by ascending priority:

Operation

Result

Notes

x or y

if x is true, then x, else y

(1)

x and y

if x is false, then x, else y

(2)

not x

if x is false, then True, else False

(3)

Notes:

This is a short-circuit operator, so it only evaluates the second argument if the first one is false.

This is a short-circuit operator, so it only evaluates the second argument if the first one is true.

not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a
== not b is a syntax error.

You might also like