Name

abs

Synopsis

abs(x)

Returns the absolute value of number x. When x is complex, abs returns the square root of x .imag**2+ x .real**2. Otherwise, abs returns - x if x is less than 0, or x if x is greater than or equal to 0. See also __abs__ in Chapter 5.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.