Skip to content
UPEEC

Arithmetic Operators

+ - * / // % ** — including true division, floor division, modulo and power.

Beginner
Comments 0
7 / 2     # 3.5  true division always gives a float
7 // 2    # 3    floor division
-7 // 2   # -4   floors toward minus infinity!
7 % 3     # 1    remainder (sign follows the divisor in Python)
2 ** 10   # 1024
divmod(17, 5)  # (3, 2)

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.