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

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s