Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 109 - 2606_PlugGPT_C7_Flipbook
P. 109

    Relational Operators or Comparison Operators
                     These operators are used to compare two values to one another.

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

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

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

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

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

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

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

                     Logical Operators
                     These operators are used to make decision on two conditions or more than two condition. Logical
                     Operators are used with boolean values and return boolean value as output.

                                                                                        Tokens and Data Types in Python  107

| 104 105 106 107 108 109 110 111 112 113 114 |