Now that we have discussed NumPy data types and have been briefly introduced to NumPy arrays, let's talk about how we can create NumPy arrays. In this section, we will create NumPy arrays using various functions. There are functions that create what are known as empty ndarray; functions for creating ndarray filled with 0s, 1s, or random numbers; and functions for creating ndarray using data. We will discuss all of these, along with saving and loading NumPy arrays from disk. There are a few ways to create arrays. One way is to use the array function, where we give an iterable object or a list of iterable objects, from which an array will be generated.
We will do this using lists of lists, but these could be lists of tuples, tuples of tuples, or even other arrays. There are ways to automatically create arrays filled with data as well. For example...