Question: Given a 1-d array and two digits: i and j, set all values between i and j to 0, in place. Use NumPy indexing to


Given a 1-d array and two digits: i and j, set all values between i and j to 0, in place. Use NumPy indexing to solve this problem. No for loops, please. Have fun with it! You can solve this in one line. #assert np.testing.assert_allclose( np5 ( np.arange (1,5), 2, 4), np.array([1, 2, 0, 0])) np.testing.assert_allclose (np5( np.arange(11), 3, 8), np.array([O, 1, 2, 3, 0, 0, 0, 0, 0. 9, 10])) np.testing.assert_allclose (np5 ( np.arange (43,55), 12, 34), np.array ([43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54])) np.testing.assert_allclose (np5( np.arange (43,55), 43, 43), np.array([43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54])) np.testing.assert_allclose (np5 ( np.arange (43,55), 43, 44), np.array([43, 0, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
