Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . 1 [ 4 pt ] In this question, we will practice slicing. Write a function called slicing _ practice that has three inputs

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

What are the different techniques used in decision making?

Answered: 1 week ago