Skip to content

Python Arithmetic Operators

How to use Python's arithmetic operators (+, -, *, /, %, //, **) for addition, subtraction, multiplication, division, modulus, floor division, and exponentiation with practical examples.

Arithmetic Operators

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

Operator Description Example
+ Add two operands or unary plus x + y + 1
- Subtract right operand from the left or unary minus x - y - 1
* Multiply two operands x * y
/ Divide left operand by the right one (always results into float) x / y
% Modulus: remainder of the division of left operand by the right x % y (remainder of x/y)
// Floor division: division that results into whole number adjusted to the left in the number line x // y
** Exponent: left operand raised to the power of right x**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
Navigation