English

When we may require to create an array initialised to zeros or ones?

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?
Chapter 6: Introduction to NumPy - Intext Questions [Page 100]

APPEARS IN

NCERT Informatics Practices [English] Class 11
Chapter 6 Introduction to NumPy
Intext Questions | Q 1. | Page 100
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×