Earn 20 XP


array( )

You can use the array() function to create a numpy array.

You can see here the first row in arr is nothing but the first inner list [1, 2, 5, 7] and similarly the other rows are other inner lists index wise.

image.png

arange( )

Use arange() function to create collection of continuous integers.

image.png

Here, 10 means arange will generate first 10 integers starting from 0. Similarly if you pass 5 in bracket, it will generate numbers from 0 to 4 (i.e. first 5 integers) [ 0, 1, 2, 3, 4 ]

zeros( )

If you want to create a collection of zero values, you can use the zeros() function available in NumPy.

The zeros() function creates an n-dimensional array of zeros. If no shape is specified, then it will create a one-dimensional array:

For instance, 5 means it will generate 5 zeros.

image.png

ones( )

In case you want collection of ones, NumPy has a function called ones().

Here 4 means ones() will generate 4 ones.

image.png

linspace( )

linspace() generates values which are equally spaced from each other.

image.png

If you don’t pass ‘num’ argument, it will generate 50 equally spaced values.