Write a NumPy program to round elements of the array to the nearest integer
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
x = np.array([-.7, -1.5, -1.7, 0.3, 1.5, 1.8, 2.0])
print("Original array:")
print(x)
x = np.rint(x)
print("Round elements of the array to the nearest integer:")
print(x)
Sample Output:
Original array: [-0.7 -1.5 -1.7 0.3 1.5 1.8 2. ] Round elements of the array to the nearest integer: [-1. -2. -2. 0. 2. 2. 2.]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال