Python: Operators

By Xah Lee. Date: . Last updated: .

Arithmetic Operators

Addition

print(3 + 4)  # 7

Substract

print(3 - 4)  # -1
print(3 + -4)  # -1

Multiplication

print(3 * 4)  # 12

Power

print(2**3)  # 8

Divide

print(11 / 5)  # 2.2

Integer Quotient

print(11 // 5)  # 2

Remainder (modulo)

print(11 % 5)  # 1

Quotient and remainder function divmod

print(divmod(11, 5))  # (2, 1)

Python, Operators