Python function abs gets the absolute value for a number

Get the absolute value for a number

abs(number) returns the absolute value of a number.

If the argument is a complex number, then math.sqrt(num.real2 + num.imag2) is returned.


print abs(-11)
print abs(110.)
print abs(11.12-21.11j)
print abs(10.213 - 10.178)

The code above generates the following result.





















Home »
  Python »
    Language Basics »




Python Basics
Operator
Statements
Function Definition
Class
Buildin Functions
Buildin Modules