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.
Live Demo#!/usr/bin/python print "abs(-45) : ", abs(-45) print "abs(100.12) : ", abs(100.12) print "abs(119L) : ", abs(119L)
When we run above program, it produces following result −
abs(-45) : 45 abs(100.12) : 100.12 abs(119L) : 119
python_numbers.htm
Advertisements