Page 126 - Plus V4 with Adobe class 6
P. 126

OPERATORS


        In  Python,  operators can be  defined  as special symbols which  perform arithmetic and  logical
        computation. The values which the operators use to get the output are called operands. For example,
        in the expression 10 – 5, 10 and 5 are operands and the minus (–) sign is the operator.

        Python divides the operators in the following categories:

        Arithmetic Operators
        Arithmetic operators perform arithmetic operations between two operands. The arithmetic operators
        are defined in the following table:

          Operator        Name                         Description                       Example        Output
                                                                                     (int 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 Integer  Divides and cuts the fractional part from          x // y          2
                      division         the result


          Program 1: To perform all the arithmetic operators
































            124  Plus (Ver. 4.0)-VI
   121   122   123   124   125   126   127   128   129   130   131