223k views
5 votes
How do you initialize a multidimensional array with NumPy?

User Indybee
by
8.3k points

1 Answer

2 votes

Final answer:

To initialize a multidimensional array with NumPy, use the np.array() function and pass a nested list as input.

Step-by-step explanation:

To initialize a multidimensional array with NumPy, you can use the np.array() function. The np.array() function takes a Python list as input and converts it into a NumPy array. To create a 2-dimensional array, you can pass a nested list as input. Here's an example:import numpy as nparr = np.array([[1, 2, 3], [4, 5, 6]])print(arr)Output:[[1 2 3] [4 5 6]]
User Giel
by
6.9k points