Latest web development tutorials

Python3 abs () function

Python3 digital Python3 digital


description

abs () function returns the absolute value.


grammar

The following is the syntax abs () method:

abs( x )

parameter

  • x - numeric expression, it may be an integer, floating point numbers, complex numbers.

return value

Function returns x (number) absolute value, if the argument is a complex number, returns its size.

Examples

The following illustrates the use of abs () method Example:

#!/usr/bin/python3

print ("abs(-40) : ", abs(-40))
print ("abs(100.10) : ", abs(100.10))

After running the above example output is:

abs(-40) :  40
abs(100.10) :  100.1

Python3 digital Python3 digital