Creation in NumPy
This lesson helps you learn how to create a NumPy array in different ways.
For using numpy, import the numpy library.
import numpy
Create an Array of Zeros
To create a numpy array containing zeros, write:
np.zeros(size)
To create an array of size 9 write:
np.zeros(9)
Here is how this array is stored in memory:
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
Z │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │ 0 │
└───┴───┴───┴───┴───┴───┴───┴───┴───┘