Python Logical Operators Example


There are the following logical operators supported by the Python language. Assume variable a holds 10 and variable b holds 20 then −

and Logical ANDIf both the operands are true then the condition becomes true.(a and b) is true.
or Logical ORIf any of the two operands are non-zero then the condition becomes true.(a or b) is true.
not Logical NOTUsed to reverse the logical state of its operand.Not(a and b) is false.