Monday, 13 March 2023

Different ways to create NumPy Array

The NumPy is used to create multidimensional array using array() method. There are many ways to create NumPy arrays. Here are some ways to create NumPy array.

1. Creating an array from a Python list:

You can create a NumPy array from a Python list using the numpy.array() function. For example
2. Creating an array of zeros:

You can create an array of zeros using the numpy.zeros() function. For example:


3. Creating an array of ones:

You can create an array of ones using the numpy.ones() function. For example:


4. Creating a range of values:

You can create an array of values that are evenly spaced between a start and end value using the numpy.arange() function. For example:

5. Creating a random array:

You can create a random array of values using the numpy.random.rand() function. For example:


 You can check the dimension of any array using ndim

Using ndim you can crate an array of specified size as 


Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

python tutorial


C Programming


Java Tutorial


Data Structures


MS Office


Database Management