Write a NumPy program to change the sign of a given array to that of a given array, element-wise.
import numpy as np x1 = np.array([-1, 0, 1, 2]) print("Original array: ") print(x1) x2 = -2.1 print("\nSign of x1 to that of x2, element-wise:") print(np.copysign(x1, x2))
Sample Output:
Original array: [-1 0 1 2] Sign of x1 to that of x2, element-wise: [-1. 0. 1. 2.]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer