{"id":7834,"date":"2023-11-03T08:16:52","date_gmt":"2023-11-03T02:46:52","guid":{"rendered":"https:\/\/python-programs.com\/?p=7834"},"modified":"2023-11-10T12:14:11","modified_gmt":"2023-11-10T06:44:11","slug":"np-ones-create-1d-2d-numpy-array-filled-with-ones-1s","status":"publish","type":"post","link":"https:\/\/python-programs.com\/np-ones-create-1d-2d-numpy-array-filled-with-ones-1s\/","title":{"rendered":"np.ones() \u2013 Create 1D \/ 2D Numpy Array filled with ones (1\u2019s)"},"content":{"rendered":"

Create a 1D \/ 2D Numpy Arrays of zeros or ones<\/h2>\n

In this article, we will learn to create array of various shapes where all the values are initialized with 0 & 1.<\/p>\n

numpy.zeros() :<\/h3>\n

A function is provided by Python’s numpy module i.e. numpy.zeros()<\/code> which will create a numpy array of given shape and where all values are initialized with 0’s.<\/p>\n

i.e.<\/p>\n

numpy.zeros(shape, dtype=float, order='C')<\/pre>\n

Arguments:-<\/p>\n