Comparison or Logical Operations in Python

Various logical, boolean and comparison operations can be conducted in Python using simple codes such as shown below

For example,  “1 == 2” is testing or whether 1 is equal to 2. The answer is obviously “False”. Similarly “x!=2 and y !=0” is testing whether both conditions are met, i.e. x is not equal to 2 and y is not equal to 0, which turns out be “False” as well in the below example as x is equal to 2.



2 thoughts on “Comparison or Logical Operations in Python

  1. Pingback: Learn Python Step by Step | RP's Blog on data science

  2. Pingback: Learn Data Science using Python Step by Step | RP’s Blog on Data Science

This site uses Akismet to reduce spam. Learn how your comment data is processed.