Articles → NUMPY → Arrays Of Ones In NumpyArrays Of Ones In NumpyIn this article, we will discuss the "ones" method in NumPy.Purpose The "ones" method returns an array of a specific size that is filled with one.Example In this example, we will create a one- dimensional and two-dimensional array.import numpy as np print(np.ones(5)) # Single dimensional arrayClick to Enlargeimport numpy as np print(np.ones((2, 3))) # Two dimensional arrayClick to EnlargePosted By - Karan Gupta Posted On - Wednesday, March 20, 2019 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
import numpy as np print(np.ones(5)) # Single dimensional array
import numpy as np print(np.ones((2, 3))) # Two dimensional array
Query/Feedback