Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 110 - 2606_PlugGPT_C7_Flipbook
P. 110

    Operator         Name                Description              Example (x=2)         Output

                                                       It returns true if both
                             and            AND                                       (x < 5) and (x < 10)      True
                                                       operands are true.

                                                       It returns true if one of the
                              or             OR                                       (x < 5) or (x < 2)        True
                                                       operands is true.

                                                       It reverses the result and     not [(x < 5) and
                             not            NOT        returns false, if the result is   (x < 10)]              False
                                                       true or vice versa.
                      Assignment Operators
                      These operators are used to assign value to a variable.

                                                                                                            Example &
                         Operator          Name                         Description                           Output
                                                                                                               (x=6)

                                                        It assigns  the  value of the  operand  on the  right
                              =          Assignment                                                            x = 6
                                                        side to the left side operand.

                                                        It adds the  right  operand to  the  left operand
                                          Addition                                                             x += 3
                             +=                         and assigns the result to the left operand. x+=3 is
                                         assignment                                                             x=9
                                                        equivalent to x=x+3.
                                                        It subtracts the right operand from the left operand
                                         Subtraction                                                           x –= 3
                             –=                         and assigns the result to the left operand. x–=3 is
                                         assignment                                                             x=3
                                                        equivalent to x=x–3.
                                                        It multiplies the right operand with the left operand
                                        Multiplication                                                         x *= 3
                             *=                         and assigns the result to the left operand. x*=3 is
                                         assignment                                                             x=18
                                                        equivalent to x=x*3.
                                                        It divides the left operand with the right operand
                                           Division                                                            x /= 3
                             /=                         and assigns the result to the left operand. x/=3 is
                                         assignment                                                             2.0
                                                        equivalent to x=x/3.
                                         Remainder      It takes the modulus of two operands and assigns the   x %= 3
                             %=
                                         assignment     result to the left operand. x%=3 is equivalent to x=x%3.  x=0
                                                        It performs floor division on operators and assigns
                                        Floor division                                                         x //= 3
                             //=                        the value to the left operand. x//=3 is equivalent to
                                         assignment                                                             x=2
                                                        x=x//3.

                                                        It performs exponential  (power) calculations
                                       Exponentiation                                                         x **= 3
                            **=                         on operators and assigns the value to  the left
                                         assignment                                                            x=216
                                                        operand. x**=3 is equivalent to x=x**3.

                      108   Premium Edition-VII

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