Question: TODO 9 Using the dummy_array given below, complete the following indexing/slicing TODOs. Index/slice the first (index 0), third (index 2), and last (index 4 or

TODO 9

Using the dummy_array given below, complete the following indexing/slicing TODOs.

Index/slice the first (index 0), third (index 2), and last (index 4 or -1) columns of the array dummy_array. Store the output into the variable column_slice.

Hint: The output shape should be a (2, 3)!

Index ONLY the first row (think about the corresponding index value) of dummy_array. Store the output into the variable row_slice.

Index ONLY the second row and first two columns of dummy_array. Store the output into the variable slice_array.

dummy_array = np.arange(10).reshape(2, -1) print(f"dummy_array output: {dummy_array}") print(f"dummy_array shape: {dummy_array.shape}")[0:2, 0:3]

# TODO 9.1 column_slice = dummy_array[:2, :3] print(f"column_slice output: {column_slice}") print(f"column_slice shape: {column_slice.shape}")

todo_check([ (column_slice.shape == (2, 3), 'column_slice did not return the correct shape of (2, 3)'), (np.all(column_slice == np.array([[0, 2, 4], [5, 7, 9]])), 'column_slice did not return the correct values!') ])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!