Python abs() Function

❮ Built-in Functions


Example

Return the absolute value of a number:

x = abs(-7.25)
Try it Yourself »

Definition and Usage

The abs() function returns the absolute value of the specified number.


Syntax

abs(n)

Parameter Values

Parameter Description
n Required. A number

More Examples

Example

Return the absolute value of a complex number:

x = abs(3+5j)
Try it Yourself »

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.