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.

Relational_Operations

Cheers!

One thought on “Comparison or Logical Operations in Python

  1. Pingback: Learn 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s