Python abs() Function

Example

Returns the absolute value of a number:

x = abs(-3.14)

Run Instance

Definition and Usage

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

Syntax

abs(n)

Parameter Value

Parameter Description
n Required. Number.

More Examples

Example

Returns the absolute value of a complex number:

x = abs(5+6j)

Run Instance