Python‎ > ‎operator‎ > ‎

operator.abs()


Return 
The built in function abs() returns the absolute value of the number. Please note that abs is not string function, therefore, it will not bring any absolute value of string. 

Syntax
operator.abs(x)
__add__
Parameter
x=number

Import module
Importing module is required in the Shell window and the Editor window.

Examples 
The method return the absolute value.
 >>> import operator
>>> operator.abs(33)
33
>>> operator.abs(-33)
33
>>> operator.abs(0)
0

__abs__ 
Return the same value as operator.abs().
 >>> operator.__abs__(1)
1
>>> operator.__abs__(-1)
1
>>> operator.__abs__(0)
0
>>> 

Comments