Arithmetic operators are the most common type of operators and also the most recognizable ones.
They allow you to perform mathematical operations.
They are:
+
: Addition-
: Subtraction*
: Multiplication/
: Division**
: Exponentiation//
: Floor Division, rounds down the result of a division%
: Modulus, gives you the remainder of a division
Let’s see a program that shows how each of them is used.
x = 5
y = 2
print('Addition:', x + y)
print('Subtraction:', x - y)
print('Multiplication:', x * y)
print('Division:', x / y)
print('Floor Division:', x // y)
print('Exponentiation:', x ** y)
print('Modulus:', x % y)
The output is:
Addition: 7
Subtraction: 3
Multiplication: 10
Division: 2.5
Floor Division: 2
Exponentiation: 25
Modulus: 1