Python abs function with programming examples
In this tutorial you will know about, Python abs function with programming examples
# Python abs() function code
# floating point number
int = -15
print('Absolute value of integer is:', abs(int))
# An integer
float = -4.32
print('Absolute value of float is:', abs(float))
# A complex number
complex = (7 - 4j)
print('Absolute value or Magnitude of complex is:', abs(complex))
Output:
Absolute value of integer is: 15
Absolute value of float is: 4.32
Absolute value or Magnitude of complex is: 8.06225774829855