THE WORLD'S LARGEST WEB DEVELOPER SITE

Python abs() Function

❮ Built-in Functions


Example

Return the absolute value of a number:

x = abs(-7.25)
Run example »

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)
Run example »

❮ Built-in Functions