We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
numpy.absolute() in Python
numpy.absolute(arr, out = None, ufunc ‘absolute’) : This mathematical function helps user to calculate absolute value of each element. For complex input, a + ib, the absolute value is .
Parameters :
arr : [array_like] Input array or object whose elements, we need to test.
Return :
An array with absolute value of each array.
Code #1 : Working
# Python program explaining
# absolute () function
importnumpy as np
arr1 =[1, -3, 15, -466]
print("Absolute Value of arr1 : \n",
np.absolute(arr1))
arr2 =[23, -56]
print("\nAbsolute Value of arr2 : \n",
np.absolute(arr2))
Output :
Absolute Value of arr1 :
[ 1 3 15 466]
Absolute Value of arr2 :
[23 56]