Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python Math fabs() function is used to return the absolute value (positive value) of the specified number.

Syntax

fabs(arg)

Parameters

arg Required. Specify a number whose absolute value need to be determined.

Return Value

Returns the absolute value (positive value) of the argument.

Example:

In the below example, fabs() function is used to return the absolute value (positive value) of the specified number.

import math

print(math.fabs(10))
print(math.fabs(-10))
print(math.fabs(-5.5))
print(math.fabs(-10.5))

The output of the above code will be:

10.0
10.0
5.5
10.5

❮ Python Math Module