Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 140 - 2625 PortGPt V2.1
P. 140

    Relational Operators

                      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:

                       Operator      Name                        Description                       Example        Output

                                                                                                 (x=8 and y=6)

                           ==        Equal     It checks if the values of two operands               x == y       FALSE
                                               are equal or not. If yes, then the condition
                                               becomes true.
                           !=      Not equal   It checks if the values of two operands are           x != y       TRUE
                                               equal or not. If the values are not equal, then

                                               the condition becomes true.
                           >        Greater    It checks if the value of left operand is greater     x > y        TRUE
                                      than     than the value of right operand. If yes, then
                                               the condition becomes true.
                           <       Less than   It checks if the value of left operand is less        x < y        FALSE
                                               than the value of right operand. If yes, then

                                               the condition becomes true.
                           >=       Greater    It checks if the value of left operand is greater     x >= y       TRUE
                                    than or    than or equal to the value of right operand. If
                                    equal to   yes, then the condition becomes true.
                           <=      Less than  It checks if the value of left operand is less         x <= y       FALSE

                                  or equal to than or equal to the value of right operand. If
                                               yes, then the condition becomes true.

                       Program 4: To show all the relational operators' functions.

                      138   Premium Edition-VI

| 135 136 137 138 139 140 141 142 143 144 145 |