Advertisements
Advertisements
Question
When we may require to create an array initialised to zeros or ones?
Long Answer
Advertisements
Solution
An array initialized to zeros or ones is useful when we need to create an array of a particular size with some initial values before performing calculations or storing data. A zero-initialized array is commonly used when we want to start with empty or zero values and update them later. A one-initialized array is useful when we need all elements to start with the value 1, such as in mathematical calculations or matrix operations. In NumPy, we can create them using np.zeros() and np.ones().
shaalaa.com
Is there an error in this question or solution?
