Skip to main content

Python Arithmetic Operators

Arithmetic Operators

Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc.

OperatorDescriptionExample
+Add two operands or unary plusx + y + 1
-Subtract right operand from the left or unary minusx - y - 1
*Multiply two operandsx * y
/Divide left operand by the right one (always results into float)x / y
%Modulus: remainder of the division of left operand by the rightx % y (remainder of x/y)
//Floor division: division that results into whole number adjusted to the left in the number linex // y
**Exponent: left operand raised to the power of rightx**y (x to the power y)

Examples

x = 10
y = 2

print(x+y) # 12
print(x-y) # 8
print(x*y) # 20
print(x/y) # 5.0
print(x//y) # 5
print(x**y) # 100