This article mainly introduces the ABS () method used in Python to return the absolute value, which is the basic knowledge in the introduction of Python, and the friends who need it can refer to the
Method ABS () returns the absolute value of x, the distance between the (positive)-x-0.
The following is the syntax for the ABS () method:
X--This is a numeric expression
This method returns the absolute value of x.
The following example shows the use of the ABS () method.
|1 2 3 4 5||#!/usr/bin/python print "ABS ( -45):", ABS ( -45) print "ABS (100.12):", ABS (100.12) print "ABS (119L):", ABS (119L)|
When we run the above program, it produces the following results:
|1 2 3||ABS ( -45): ABS (100.12): 100.12 abs (119L): 119|