Python Arithmetic Operators:
|We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.|
(1) Python supports arithmetic operators that are used to perform the four basic arithmetic operations as well as modular division, floor division, and exponentiation.
|+||Addition||a + b|
|–||Subtraction||a – b|
|*||Multiplication||a * b|
|/||Division||a / b|
|%||Modulus||a % b|
|**||Exponents||a ** b|
|//||Floor Division||a // b|
(2) Example of four basic arithmetic operators is given below.
(3) Example of modular division, floor division, and exponentiation is given below.
- Modular Division (%)- Divides the operand on the left by the operand on the right and returns the remainder.
- Floor Division (//)- Divides the operand on the left by the operand on the right and returns the quotient by removing the decimal part. It is sometimes also called integer division.
- Exponentiation (**)- Performs exponential (power) calculation on operands. That is, raise the operand on the left to the power of the operand on the right. For example- 9**2 = 9*9; 9**3 = 9*9*9 etc.