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

abs

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


Import & Availability

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

Overview & Signature

abs(x, /)

Return the absolute value of the argument.

Usage

assert abs(-42) == 42
assert abs(-3.5) == 3.5
assert abs(3 + 4j) == 5.0   # Euclidean magnitude for complex numbers

Gotchas

REPL Inspect

help(abs)

Linked from

Related notes