This Book deals with What is an Operator and what are the various operators in Python.
Note : This section is mandatory to complete.
2. Arithmetic Operators
- Arithmetic Operators are operators which are used to perform mathematical calculations in a program. The below table gives the clear idea about Arithmetic operators in Python.
|
Operator |
Usage |
Description |
Example |
|
Addition (+) |
a+b |
Add values on either side of operator |
10+6=16 |
|
Subtraction (-) |
a-b |
Subtracts the right operand from left operand |
11-3=8 |
|
Multiplication (*) |
a*b |
Multiply values on either side of operator |
5*2=10 |
|
Division ( / ) |
a/b |
Divides the left operand by the right operand (returns a float value) |
5/2= 2.5 & 11/3 = 3.666666 |
|
Modulus ( % ) |
a%b |
Returns a remainder of the division of the left operand by the right operand |
5%2 = 1 & 11%3 = 2 |
|
Exponentiation ( ** ) |
a**b |
Returns exponent – left operand raised to the right operand |
3**2 = 9 5**3 = 125 |
|
Floor Division ( // ) |
a//b |
Divides the left operand by the right operand (returns quotient without float value) |
5//2 = 2 11/3 =2 |
The following video deals with best examples for Arithmetic Operators in Python.
"Python - Arithmetic Operators (Lesson 3)" by Andy Dolinski is licensed under CC BY-SA 3.0