Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started