Loading lesson path
Arithmetic operators are used with numeric values to perform common mathematical operations:
+
Formula
Addition x + yTry it »
Formula
Subtraction x - yTry it » *
Formula
Multiplication x * yTry it » /
Formula
Division x / yTry it » %
Try it » Exponentiation x y Try it » // Floor division x // y Try it »
Here is an example using different arithmetic operators:
Example x = 15 y = 4 print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x % y)
print(x ** y)
print(x // y)/ - Division (returns a float) // - Floor division (returns an integer)
x = 12 y = 5 print(x / y)Floor division always returns an integer. It rounds DOWN to the nearest integer:
x = 12 y = 5 print(x // y)