Write a NumPy program to change the sign of a given array to that of a given array, element-wise
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
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.]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال