Recall & Review
beginner
What does the shape of a NumPy array represent?
The shape of a NumPy array shows the size of the array in each dimension. It is a tuple where each number tells how many elements are in that dimension.
Click to reveal answer
beginner
How many dimensions does a 1D array have?
A 1D array has exactly one dimension. It looks like a simple list of values.
Click to reveal answer
beginner
What is the shape of this array? np.array([[1, 2, 3], [4, 5, 6]])
The shape is (2, 3) because there are 2 rows and 3 columns.
Click to reveal answer
beginner
What does the ndim attribute of a NumPy array tell you?
The ndim attribute tells you how many dimensions the array has. For example, 1 for 1D, 2 for 2D, and so on.
Click to reveal answer
intermediate
How can you change the shape of an array without changing its data?
You can use the reshape() method to change the shape of an array while keeping the same data.
Click to reveal answer
What is the shape of a 3D array with dimensions 4, 3, and 2?
✗ Incorrect
The shape tuple lists dimensions in order: (4, 3, 2).
If an array has shape (5,), what does this mean?
✗ Incorrect
Shape (5,) means one dimension with 5 elements.
Which NumPy attribute gives the number of dimensions of an array?
✗ Incorrect
The ndim attribute tells the number of dimensions.
What happens if you try to reshape an array to a shape that does not match the total number of elements?
✗ Incorrect
Reshape requires the total number of elements to stay the same, otherwise it raises an error.
What is the shape of np.array([[1, 2], [3, 4], [5, 6]])?
✗ Incorrect
There are 3 rows and 2 columns, so shape is (3, 2).
Explain what array shape and dimensions mean in simple terms.
Think about rows and columns in a table.
You got /4 concepts.
Describe how you can change the shape of an array and what you must be careful about.
Imagine rearranging blocks without adding or removing any.
You got /4 concepts.