The logical operators are used to perform logical operations on Boolean values.
Gives
True
or False
as the result. Following are the logical operators
- and
- or
- not
Logical AND Operator
Gives
True
if both the booleans are true else, it gives False
Code
PYTHON
Output
Examples of Logical AND
Code
PYTHON
Step by Step Explanation
Output
Logical OR Operator
Gives
True
if any one of the booleans is true else, it gives False
Code
PYTHON
Output
Examples of Logical OR
Code
PYTHON
Step by Step Explanation
Output
Logical NOT Operator
Gives the opposite value of the given boolean.
Code
PYTHON
Output
Examples of Logical NOT
Code
PYTHON
Step by Step Explanation
Output
Summary
- Logical AND Operator gives Trueif all the booleans are true.
- Logical OR Operator gives Trueif any of the booleans are true.
- Logical NOT Operator gives the opposite value