Page 121 - ConceptGP_C8_Fb
P. 121
Logical Operators
Logical operators are used to evaluate and decide. Python supports the following logical
operators:
Operator Name Description Example (x=2) Output
and AND It returns true, if both operands (x < 5) and (x < 10) TRUE
are true.
or OR It returns true, if one of the (x < 5) or (x < 2) TRUE
operands is true.
not NOT It reverses the result, returns false, not [(x < 5) FALSE
if the result is true or vice versa. and (x < 10)]
Program 3: To perform all the logical operators.
The result of the above program will be:
Relational Operator
Relational operators are used to compare the value of the two operands and returns True
or False accordingly. The relational operators are described in the following table:
Operator Name Description Example Output
(x=8 andy=6)
== Equal It checks if the values of two operands x == y FALSE
are equal or not. If yes, then the condition
becomes true.
Introduction to Python Programming 119

