Operators are used to perform operations on values and variables. These are special characters that perform arithmetic and logical calculations. The value the operator operates on is known as operand .
Table of Content
Boolean Operators
In Python, Boolean operators are used in conditional expressions (True or False). They perform logical AND , logical OR and logical NOT .
OPERATOR  DESCRIPTION  SYNTAX 

and  Logical AND: True if both the operands are true  x and y 
or  Logical OR: True if either of the operands is true  x or y 
not  Logical NOT: True if operand is false  not x 
Boolean AND operator
Boolean operator returns True
if both operands are True, otherwise it returns False
.
Example # 1:
# Python program for demonstration
# boolean and operator
a
=
10
b
=
10
c
=

10
if
a"
0
and
b"
0
:
print
(
"The numbers are greater than 0"
)
if
a"
0
and
b"
0
and
c"
0
:
print
(
"The numbers are greater than 0"
)
else
:
print
(
"Atleast one number is not greater than 0 "
)
Exit :
The numbers are greater than 0 Atleast one number is not greater than 0
Example # 2 :

Output:
Atleast one number has boolean value as False
Note. If the first expression evaluates to false when using the and operator, then subsequent expressions are not evaluated.
Logic or operator
Boolean or operator returns True if any of the operands — True.
Example # 1:

Either of the number is greater than 0 No number is greater than 0
Example # 2 :

Exit:
Atleast one number has boolean value as True
Note. If the first expression evaluates to True during use or operator, then further expressions not evaluated.
Logical nonoperator
Logical nonoperator operation with a single boolean value. If boolean True
returns False
and vice versa.
Example :
# Python program for demonstration
# logical nonoperator
a
=
10
if
not
a:
print
(
"Boolean value of a is True"
)
if
not
(a
%
3
=
=
0
or
a
%
5
=
=
0
):
print
(
"10 is not divisible by either 3 or 5"
)
else
:
print
(
" 10 is divisible by either 3 or 5 "
)
Exit:
10 is divisible by either 3 or 5
Boolean operator evaluation order
For multiple operators, Python always evaluates the expression from left to right ... You can check this with the example below.
Example :
Exit :
Method called for value: 1 Method called for value: 5 Atleast one of the number is positive
Shop
Latest questions
Wiki
# Python program for demonstration
# order of logic evaluation
# statements
def
order (x):
print
(
"Method called for value:"
, x)
return
True
if
x"
0
else
False
a
=
order
b
=
order
c
=
order
if
a (

1
)
or
b (
5
)
or
c (
10
):
print
(
"Atleast one of the number is positive" )