Page 119 - ConceptGP_C8_Fb
P. 119

Program 1: To perform all the arithmetic operators.
























                The result of the above program is:




















                Assignment Operators

                The assignment operators are used to assign the value of the right expression to the left
                operand. The assignment operators are described in the following table:


                 Operator Name                  Description                                               Example
                      =       Assignment        It assigns the value of operand on the right side           x = 5
                                                to the left side operand.

                     +=       Addition          It adds right operand to the left operand and               x += 3
                              assignment        assigns the result to left operand. x+=3 is
                                                equivalent to x=x+3.

                     –=       Subtraction       It subtracts right operand from the left operand            x –= 3
                              assignment        and assigns the result to left operand. x–=3 is
                                                equivalent to x=x–3.
                     *=       Multiplication    It multiplies right operand with the left operand           x *= 3
                              assignment        and assigns the result to left operand. x*=3 is

                                                equivalent to x=x*3.




                                                                  Introduction to Python Programming  117
   114   115   116   117   118   119   120   121   122   123   124