The builtin abs()
function returns the absolute value of a number.
The function takes only one argument i.e the number which we want to get the absolute value of.
abs(num)
copy
It supports all the numerical data types such as integers, floats and complex numbers. For integers and the floating point numbers; the absolute value is the distance between that number and zero on a number line. It is the magnitude or size of the number without regard to its sign.
The absolute value of a positive number is the number itself while the absolute value of a negative number is its positive counterpart. For example, the absolute value of 3 is 3, and the absolute value of -3 is also 3.
For complex numbers; the absolute value is the distance from the origin (0,0) to the point (a,b) in the complex plane. This value is calculated using the Pythagorean theorem, for example the absolute value of 3 + 4j is 5.
The function returns a float value.