Page 110 - TP_Pluse_V2.2_Class_6
P. 110

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 the right-hand operand from the          x – y          4
                                                left-hand operand.
                       *       Multiplication   Multiplies values on either side of the operator.  x * y         21


                   Operator Name                Description                                      Example       Output
                                                                                               (x=7 and y=3)

                       /      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 the remainder.
                       **     Exponentiation    Performs exponential (power) calculation on        x ** y        343
                                                operands.

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


                   Program 1: To perform all the arithmetic operators

                      Program1.py
                   File  Edit  Format   Run    Options   Window    Help


                   #Program to perform from arithmetic operators
                   a = 9
                   b = 4
                   add = a + b    #Addition
                   sub = a - b    #Subtraction
                   mul = a * b    #Multiplication
                   div = a / b    #Division
                   divl =a // b   #Floor Division
                   mod = a % b    #Modulus
                   power = a **b  #Power
                   print ("Sum is : ", add,  " Difference is : " , sub,  " Product is : " ,
                   mul, " Decimal division is : ", div, " Integer division is : " ,divl,
                   " Remainder is : ", mod, " Raised to the power is : ", power)




                      Output
                   Sum is :  13  Difference is :  5  Product is :  36  Decimal division is
                   :  2.25  Integer division is :  2  Remainder is :  1  Raised to the power
                   is : 6561




                  108   Plus (Ver. 2.2)-VI
   105   106   107   108   109   110   111   112   113   114   115