Page 90 - TP-Play_V-2.0_Book-6
P. 90

Let us learn about various Python operators.
            Arithmetic Operators

            Arithmetic operators  perform arithmetic operations between  two operands.  The arithmetic

            operators are defined in the following table:

             Operator         Name                         Description                    Example   Output

                                                                                          (x=7 and
                                                                                             y=3)

                 +       Addition          Adds values on either side of the operator.       x + y        10

                 –       Subtraction       Subtracts right hand operand from left            x – y         4
                                           hand operand.

                  *      Multiplication    Multiplies values on either side of the           x * y        21

                                           operator.

                  /      Division          Divides left hand operand by right hand           x / y       2.33
                                           operand.

                 %       Modulus           Divides left hand operand by right hand          x % y          1
                                           operand and returns remainder.

                 **      Exponentiation Performs exponential (power) calculation            x ** y       343

                                           on operands.

                 //      Floor or          Divides and cuts the fractional part from        x // y         2
                         Integer           the result.
                         division


            Program 1: To perform all the arithmetic operations




























             90       Play (Ver. 2.0)-VI
   85   86   87   88   89   90   91   92   93   94   95