Python Number abs() Method
Advertisements
Description
The method abs() returns absolute value of x - the (positive) distance between x and zero.
Syntax
Following is the syntax for abs() method
abs( x )
Parameters
x -- This is a numeric expression.
Return Value
This method returns absolute value of x.
Example
The following example shows the usage of abs() method.
#!/usr/bin/python print "abs(-45) : ", abs(-45) print "abs(100.12) : ", abs(100.12) print "abs(119L) : ", abs(119L)
Let us compile and run the above program, this will produce the following result:
abs(-45) : 45 abs(100.12) : 100.12 abs(119L) : 119