Copyright © tutorialspoint.com

# Python Number fabs() Function

## Description:

This function returns the absolute value of x.

## Syntax:

    import math

    math.fabs( x )

Note: This function is not accessible directly so we need to import math module and then we need to call this function using math static object.

## Parameters:

Here is the detail of parameters:

- x: This is a numeric expression.

## Return Value:

The absolute value of x.

## Example:

    #!/usr/bin/python
    import math   # This will import math module

    print "math.fabs(-45.17) : ", math.fabs(-45.17)
    print "math.fabs(100.12) : ", math.fabs(100.12)
    print "math.fabs(100.72) : ", math.fabs(100.72)
    print "math.fabs(119L) : ", math.fabs(119L)
    print "math.fabs(math.pi) : ", math.fabs(math.pi)

This will produce following result:

    math.fabs(-45.17) :  45.17
    math.fabs(100.12) :  100.12
    math.fabs(100.72) :  100.72
    math.fabs(119L) :  119.0
    math.fabs(math.pi) :  3.14159265359

Copyright © tutorialspoint.com