Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 125 - 2609_Logiccode
P. 125

    RELATIONAL OPERATOR
                     Relational operators are used to compare the value of the two operands and returns True or

                     False accordingly. The relational operators are described in the following table:

                                                                                                Example
                      Operator    Name         Description                                                      Output
                                                                                                (x=8 and y=6)

                          ==      Equal to     It checks if the values of two operands are  x == y              False
                                               equal or not. If the values are equal, then the
                                               condition becomes true.

                          !=      Not equal    It checks if the values of two operands are  x != y              True
                                  to           equal or not. If the values are not equal, then

                                               the condition becomes true.
                          >       Greater      It checks whether the value of the left operand  x > y           True

                                  than         is greater than the value of the right operand.
                                               If it is, the condition evaluates to true.

                          <       Less than    It checks whether the value of the left operand  x < y           False
                                               is less than the value of the right operand. If it
                                               is, the condition evaluates to true.

                          >=      Greater      It checks whether the value of the left operand  x >= y          True
                                  than or      is greater than or equal to the value of the right
                                  equal to     operand. If it is, the condition evaluates to true.

                          <=      Less than    It checks whether the value of the left operand  x <= y          False
                                  or equal to is less than or equal to the value of the right
                                               operand. If it is, the condition evaluates to true.

                     Program: To show all the relational operators� functions.

                                                                                                      More on Python  123

| 120 121 122 123 124 125 126 127 128 129 130 |