Arithmetic Operators in Python



Arithmetic Operators 


Python does a good job of processing mathematical expressions with its basic arithmetic operators. You can easily make programs to automate tasks such as computing tax, tips, discounts, or rent.


           
+
Addition
adds   the      value  of        the      left      and     right            operands
-
Subtraction
subtracts       the      value  of        the      right   operand            from   the value      of        the      left      operand
*
Multiplication
multiplies      the      value  of        the      left      and            right   operand
/
Division
divides           the      value  of        the      left      operand            by       the      right operand
**
Exponent
performs      exponential  calculation
%
Modulus
returns          the      remainder    after   dividing         the            left      operand with          the      right   operand
//
Floor
Division
division          of        operands      where            the            solution         is         a          quotient left            after   removing      decimal         numbers
           
           
Addition,      subtraction, multiplication,         and     division          are      the      most   basic            operators     and     are invoked by       entering        the      following      expressions:

Addition:

           
>>>1  +          3
4
           
Subtraction:
           
>>>10           –          4
6
           
Multiplication:
>>>4  *          2
8
           
Division:
>>>10           /          2
5.o
           
           

Exponent

           
Exponential  calculation    is         invoked         by       raising            the      first     number         to            the      power            defined          by       the number after   the      **       operator:
           
>>>2**3                                                                                                                                                                  2          raised to        the      power            of        3
8
           

Modulus

           
The     modulus        operator       gives   the      remainder    after   performing  division:
           
>>>17           %         5
2
           
           

Floor  Division

           
Floor  division,        on       the      other  hand, returns          the      quotient        after   removing            fractional      numbers:
           
>>>17           //         5
3
            

Comments