Dev Helpers

Python / Numbers and statistics

Use quotient and remainder

Dev Helpers · August 23, 2026

A page number and offset are the quotient and remainder of the same division. divmod returns both from one operation.

Worked example

print(divmod(3671, 60))

Result

(61, 11)

Implementation notes

Negative operands follow Python's floor-division rules. Confirm the expected quotient and remainder if your page offsets can run backwards.

Try it yourself

Use the exact last slot on a page, followed by the first slot on the next.

Open the Python example →

Editorial date August 23, 2026 · Published December 6, 2026

Related articles

Run an async function

An async function call creates a coroutine. A top-level runner supplies the event loop that executes it.

Transpose a matrix

Transposing rows into columns assumes a decision about uneven rows. Ordinary zip stops at the shortest input.

Unpack with a remainder

Starred unpacking separates a fixed header from a variable-length tail. It still requires enough elements for the fixed positions.