On this page
  1. divmod
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

divmod

Prev: dir | Up: __builtins__ | Next: enumerate
Rel: abs, max, min, pow, round
Ref: docs.python.org — divmod
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import divmod

Overview & Signature

divmod(x, y, /)

Return the tuple (x//y, x%y). Invariant: div*y + mod == x.

Usage

mins, secs = divmod(135, 60)
assert (mins, secs) == (2, 15)

Gotchas

REPL Inspect

help(divmod)

Linked from

Related notes