Python Arithmetic Operators
Following are the Arithmetic Operators (also known as Mathematical Operators) in Python which are used to perform the arithmetic operations,
Operator |
Name |
Description |
Example a=10,b=20 |
+ |
Addition |
Returns the addition of two numbers |
a+b=30 |
- |
Subtraction |
Returns the subtraction of two numbers |
a-b = -10 |
* |
Multiplication |
Returns the product (multiplication) of two numbers |
a*b = 30 |
/ |
Division |
Returns the result of the divide operation of two numbers |
a = 10,b=3 a/b=3.333 |
% |
Modulus |
Returns the remainder of the two numbers |
a=10,b=3 a%b=1 |
** |
Exponent |
Returns the result of exponential operation of two numbers |
a=2, b= 3 a**b = 8 |
// |
Floor division |
Returns the result of the floor division i.e., returns the result without decimal points for positive numbers and returns the floored value if any of the operands is negative |
a=10,b=3 a//b=3 a=10,b=-3 a//b=-4
|
Python program to demonstrate the example for arithmetic operators
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer