Python abs () function
description
abs () function returns the absolute value.
grammar
The following is the syntax abs () method:
abs( x )
parameter
- x - numeric expression.
return value
Function returns x (number) absolute value.Examples
The following illustrates the use of abs () method Example:
#!/usr/bin/python print "abs(-45) : ", abs(-45) print "abs(100.12) : ", abs(100.12) print "abs(119L) : ", abs(119L)
After running the above example output is:
abs(-45) : 45 abs(100.12) : 100.12 abs(119L) : 119