Q:

Write a NumPy program to calculate the absolute value element-wise

0

Write a NumPy program to calculate the absolute value element-wise.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([-10.2, 122.2, .20])
print("Original array:")
print(x)
print("Element-wise absolute value:")
print(np.absolute(x))

Sample Output:

Original array:                                                        
[ -10.2  122.2    0.2]                                                 
Element-wise absolute value:                                           
[  10.2  122.2    0.2]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now