Loading...
Extract portions of a 2D NumPy array using slicing.
For 2D arrays:
Write a function slice_2d(arr) that returns a dictionary with:
3×3 array [[1,2,3],[4,5,6],[7,8,9]]
{'top_left': [[1, 2], [4, 5]], 'bottom_row': [7, 8, 9], 'right_col': [3, 6, 9], 'center': 5}[:2,:2] for top-left, [-1,:] for bottom, [:,-1] for right, center at (1,1)