Arithmetic Operators
What are Arithmetic Operators
Arithmetic operators are symbols that performs mathematical operations
There are seven arithmetic operators in Python
Here is an overview of arithmetic operators
Operator | Description | Example |
---|---|---|
+ | Addition | x + y = 30 |
- | Substraction | x - y = 10 |
- | Multiplication | x * y = 200 |
- | Division | x / y = 2.0 |
- | Floor Division | x // y = 2 |
- | Exponent | x ** y = 4 # if x = 2, y = 2 |
% | Modulus | x % y = 0 |
Addition Operator
Addition operator represented by +
adds the object(value) on its left with object(value) on its right and then returns the result
Example
Subtraction Operator
Substraction operator symbolised by -
subtracts the value on its right from the value on its left and then returns the result.
Example
Multiplication Operator
Multiplication operator represented by *
multiplies the operand(value) on its left by the value or object on its right, and returns the result.
Example
Division Operator
Division operator represented by /
divides the value or object on the its left by the operand(value) on its right, and then returns the result.
Example
Floor Division Operator
Floor Division operator represented by //
divides the value or object on the its left by the operand(value) on its right, and then returns the result by discarding the floating points.
Example
Exponentiation Operator
Example
Modulus Operator
Modulus operator represented by %
divides the value or object on the its left by the operand(value) on its right, and then returns the remainder.