Exam2021_01 Flashcards
(26 cards)
my_arr is reshaped to have 3 columns, and the number of rows is inferred automatically by numpy (using -1).
The shape of my_arr would be (2, 3) because the original array has 6 elements, and reshaping it to have 3 columns results in 2 rows.
The reshaped array would look like this:
[[0 1 2]
[3 4 5]]
The line my_arr[0] would select the first 2D array (of shape (4, 5)) from the 3D numpy array my_arr.
The line my_arr[0, 0] would select the first 1D array (of shape (3,)) from the 3D numpy array my_arr.
The AttributeError is raised but not caught by the except block because the except block is only looking for a ValueError. The finally block executes regardless of whether an exception was raised or not, and after the finally block executes, the AttributeError will propagate up the call stack.
So, the output will be:
done
And then the AttributeError will be raised.