Question: Exercise 1 Using numpy and its functions: a) Create an array of 100 elements all equal to 1, assign the array to a variable named

Exercise 1 Using numpy and its functions: a) Create an array of 100 elements all equal to 1, assign the array to a variable named one_array , and print it. In [6] : In [ ] : b) Create an array of 50 elements all equal to 0 , assign the array to a variable named zero_array , and print it. In [ ] : In [ ] : Exercise 2 Given the following one-dimensional numpy arrays: In[]:x=numpy.array([39,48,15,54,44,25,3,46,45,19,20,37,25,4,4,25,46,10,49,11,26,44,15,38,0,10,53,19,34,51,26,54,11,16]) a) Create an array named sum_xy that is the result of adding x and y, and print it. In [ ] : In [ ] : b) Create an array named diff_xy that is the result of subtracting y from x, and print it. In [ ] : In [ ] : Exercise 3 Given the following array: In [ ] : a) Using [ ] , access the first, fifth and last elements, add them, assign the result to a varaible named res, and print it. In [ ] : In [ ] : b) Using slicing, grab a slice that goes from the first to the third element (included), asign it to a variable named slice_1, and print it. In [ ] : In [ ] : c) Using slicing, grab the slice that contains the three elements in the middle of arr, assign the resulting array to a variable named slice_mid. Then, subtract 17 from all the elements in slice_mid (do not use for statements), assign the result to a variable named slice_mid_17, and print both slice_mid and slice_mid_17. In [ ] : In [ ] : d) Using slicing, create an array that is the result of adding the first three elements with the last three elements, assign it to a variable named s lice_sum, and print it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
