Python- relational operators

Hello Boys!


Good to reconnect with you.

Today we are going to begin with the introduction of those topics, which will give an interesting turn to your journey of knowledge of programming. 


Learning Outcomes 

By the end of this blog you will be able to:

 *  Elucidate Relational Operators
 *  Understand the logic behind the Relational Operators



Let's begin...

Have you ever taken any decision? 

I am sure you must have. 

Just think once...     What do you need to do when there's a situation to take decision?


Before giving the answer just look at this video and find how is this man selecting the correct door. 




I hope the video was enjoyable.

So did you notice, that as and when he got to know that there's a guard behind the door, he left it and selected another one

So basically he compared two doors. One with guard and another without guard. Then he chose accordingly

This is how we take our decisions... i.e. by Comparing

Like if your friend tells you to check his result, then you will just compare his percentage with 33. If it is greater than or equal to 33, then you will inform him that HE IS PASS.

**************************************************************************

Such comparison is possible in Python too. 

It is possible with the use of RELATIONAL OPERATORS

These operators are useful in doing comparison. Therefore these are also known as comparison operators because they compare two values and return the Boolean value, i.e. either true or false. 

Let us try to understand with a small example... 

What will you say, if I ask that:
  • Is 5 greater than 6? 
Very much obvious answer...  You will say NO. 

Let's write the same thing in Python Language and see the answer: 


The only difference is that the words 'GREATER THAN' are replaced by the symbol '>' and the word 'NO' is replaced by the value 'False'

This symbol ( > ) is also a Relational Operator in Python

******************************************************************
Let us understand all the Relational Operators one by one.
_____________________________________________________________________

  • This is GREATER THAN operator. 
  • It returns 'True' if the value in its LHS is bigger/greater than the value in its RHS
  • similarly, It returns 'False' if the value in its LHS is smaller than or equal to the value in its RHS. 
_____________________________________________________________________
>= 

  • This is GREATER THAN OR EQUAL TO operator
  • It returns 'True' if the value in its LHS is bigger/greater than or equal to the value in its RHS
  • similarly, It returns 'False' if the value in its LHS is smaller than the value in its RHS. 
_____________________________________________________________________

  • This is LESS THAN operator.
  • It returns 'True' if the value in its LHS is smaller than the value in its RHS
  • similarly, It returns 'False' if the value in its LHS is greater than or equal to the value in its RHS. 
_____________________________________________________________________
<= 

  • This is LESS THAN OR EQUAL TO operator.
  • It returns 'True' if the value in its LHS is smaller than or equal to the value in its RHS
  • similarly, It returns 'False' if the value in its LHS is bigger/greater than the value in its RHS
_____________________________________________________________________
==

  • This is EQUALS TO operator.
  • It returns 'True' if both LHS and RHS values are same/equal, otherwise 'False'.
_____________________________________________________________________
!=
  • This is NOT EQUALS TO operator.
  • It returns 'True' if both LHS and RHS values are not equal to each other, otherwise 'False'.
_____________________________________________________________________


Please look at the following Python Shell screen.

Just observe yourself to understand the behaviour of these operators. 


Now fill the following form to assess your knowledge. 





That's all for today...

Kindly finish your work before connecting to the next blog. 

In our next blog we will start with the implementation of the RELATIONAL OPERATORS using IF Statements. 


Thank you students!!

God Bless You

Computer Science Department
(Middle School)

Comments

  1. Good morning maam
    this question would be our first question of python

    ReplyDelete
    Replies
    1. We had done relational operators last year. Now will take up the same from the point of view of Python statements----example IF

      Delete
  2. Good morning ma'am
    Ashwanth is present
    10-C

    ReplyDelete
  3. Good morning ma'am
    Matthew Jayakumar present
    10 -C

    ReplyDelete
  4. We will have a GOOGLE MEET class tomorrow. I shall take up the exercise shared today and the next topic tomorrow. Kindly prepare accordingly.

    ReplyDelete
  5. Good morning ma'am.
    Gautam Gupta 10-C

    ReplyDelete
  6. Ma'am I couldn't find q 2,3,4 pls can you direct me

    ReplyDelete
    Replies
    1. Which blog??
      today's or last time's blog...

      Delete
    2. Last blog contained q1) and today's one contains q5) where are the middle ones. Please clarify

      Delete
    3. This comment has been removed by the author.

      Delete
  7. Good morning ma'am
    Adam Saviour Kerketta
    is Present ma'am

    ReplyDelete
  8. Present Ma'am
    Archbill Xalxo 10-C

    ReplyDelete
  9. Present Ma'am
    - George Gomes

    ReplyDelete

Post a Comment

Popular posts from this blog

Python-IF(Prac)

Python-IF command