Advertisements
Advertisements
प्रश्न
Create the following NumPy arrays:
A 2-D array called ones having 2 rows and 5 columns and all the elements are set to 1 and dtype as int.
कोड लेखन
Advertisements
उत्तर
A 2-D NumPy array called ones having 2 rows and 5 columns, with all elements set to 1 and data type as integer, can be created as follows:
import numpy as np
ones = np.ones((2, 5), dtype=int)
print(ones)
Output:
[[1 1 1 1 1] [1 1 1 1 1]]
Thus, ones is a 2-D array with 2 rows, 5 columns, and integer values of 1.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
