Skip to content

Reference: Numbers and maths

Quick-lookup pages. Short, dense, designed to skim. If you're here to learn the topic for the first time, start with Learn instead.

Pages in this section

  • math module reference — the everyday math functions on one page: powers and logs, trigonometry, rounding, combinatorics, constants, and the special-value tests (isnan, isinf, isclose).
  • Number formatting reference — the number side of the format mini-language: type codes (f, e, g, %, d, b, o, x, n), precision, grouping, sign, and width/fill/alignment, with examples.
  • Numeric types and operators referenceint, float, complex, Decimal, Fraction; the arithmetic and bitwise operators; and the numeric built-ins (abs, round, divmod, pow, bin/hex/oct, and conversions).