Question: Part 4 : Slicing Practice 4 . 1 [ 4 pt ] In this question, we will practice slicing. Write a function called slicing _

Part 4: Slicing Practice
4.1[4 pt] In this question, we will practice slicing. Write a function called slicing_practice that has three inputs called practice_array (a numpy array that has at least five elements in it), num1(a real number), and num2(a real number), and returns a dictionary with five key-value pairs:
first_five: the first 5 elements of practice_array (as a numpy array)
last_five: the last 5 elements of practice_array (as a numpy array)
last_five_backwards: the last 5 elements of practice_array in reverse order (as a numpy array)
middle_five: the middle 5 elements of practice_array (as a numpy array)
num1_to_num2: the segment of practice_array that starts with the first instance of num1 and ends with the first instances of num2(as a numpy array); notice that num1 and num2 are elements in practice_array (not indices).
If the shape of practice_array is such that there is no "middle five" but there is a "middle six", then take the first five numbers of the middle six. For example, the middle five of 1,2,3,4,5,6 would be 1,2,3,4,5. There is one more important instruction for this question: for your key-value pair with the key 'last_five', please replace the first element of that numpy array with the number 0.
 Part 4: Slicing Practice 4.1[4 pt] In this question, we will

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!