Arithmetic Operators are used to perform mathematical operation like addition, multiplication, division, subtraction, etc.
Operators | Description | Syntax |
Addition(+) | Add two operands. | a+b |
Subtraction(-) | Subtract two operands. | a-b |
Multiplication(*) | Multiply two operands. | a*b |
Division(/) | Divides the first operand by the second. | a/b |
Modulus(%) | It returns the remainder when first operand is divided by the second. | a%b |
Exponentiation(**) | It returns first raised to power second. | a**b |
Floor division(//) | It divides that results into whole number adjusted to the left in the number line. | a//b |
Example:
a = 4
b = 3
c = a+b
print("Addition: c = ",c)
c = a-b
print("Subtraction: c = ",c)
c = a*b
print("Multiplication: c = ",c)
c = a/b
print("Division: c = ",c)
c = a%b
print("Modulus: c = ",c)
c = a**b
print("Exponentiation: c = ",c)
c=a//b
print("FloorDivision: c = ",c)
Output:
ddition: c = 7 Subtraction: c = 1 Multiplication: c = 12 Division: c = 1.3333333333333333 Modulus: c = 1 Exponentiation: c = 64 FloorDivision: c = 1