DEV Community

Punitha
Punitha

Posted on

Zeros, Ones, Empty and Default Value

Create an Array of Zeros

What is np.zeros()?

  • np.zeros() creates an array where all elements are 0.

Step 1:

Output:

Create an Array of Ones

What is np.ones()?

  • np.ones() creates an array where all elements are 1.

Step 1:

Output:

Create an Empty Array

What is np.empty()?

  • np.empty() creates an array with a specified shape without initializing its values.

Step 1:

Output:

Create an Array with a Default Value

What is np.full()?

  • np.full() creates an array where every element has the same specified value.

Step 1:

Output:

Top comments (0)