English

Create the following NumPy arrays: A 1-D array called zeros having 10 elements and all the elements are set to zero.

Advertisements
Advertisements

Question

Create the following NumPy arrays:

A 1-D array called zeros having 10 elements and all the elements are set to zero.

Code Writing
Advertisements

Solution

We can create a 1-D NumPy array named zeros containing 10 elements, with all elements set to zero, using the zeros() function.

import numpy as np
zeros = np.zeros(10)
print(zeros)

Output:

[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

Thus, zeros is a 1-D array containing 10 zero elements.

shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Introduction to NumPy - Exercise [Page 113]

APPEARS IN

NCERT Informatics Practices [English] Class 11
Chapter 6 Introduction to NumPy
Exercise | Q 4. a) | Page 113
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×