Skip to content
scipython.com

Q6.1.3Creating a NumPy array #2

What is the difference, if any, between the following statements:

>>> a = np.array([0,0,0])
>>> a = np.array([[0,0,0]])
Show solution

np.array([0,0,0]) creates a one-dimensional array with three elements; a = np.array([[0,0,0]]) creates a \(1 \times 3\) two-dimensional array (i.e. a[0] is the one-dimensional array created in the first example).