Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2: Array Processing (15 points) Given a 9-by-9 matrix of random integers from 0 to 99 : 50] : np.random.seed (1) arr =npr random. randint

image text in transcribedimage text in transcribed

Q2: Array Processing (15 points) Given a 9-by-9 matrix of random integers from 0 to 99 : 50] : np.random.seed (1) arr =npr random. randint (100, size =(9,9)) arr 50] : array ([[37,12,72,9,75,5,79,64,16] [1,76,71,6,25,50,20,18,84], [11,28,29,14,50,68,87,87,94], [96,86,13,9,7,63,61,22,57], [1,0,60,81,8,88,13,47,72], [30,71,3,70,21,49,57,3,68], [24,43,76,26,52,80,41,82,15], [64,68,25,98,87,7,26,25,22] [9,67,23,27,37,57,83,38,8]]) Q2.1 Observe that each 99 matrix is essentially nine blocks of 33 matrix. Write a Python code to calculate the mean value for each of the 33 matrix. Hint: use array slicing to index each of the 9 sub-block. [1] Q2.2: What is the maximum value in the array? What is the index of the maximum value? II Note: use argmax(). Q2.3: What is the minumum value in the array? What is the index of the minumum value? Note: use argmin() Q2.4 Swap the positions of the maximum data with the minimum data. Print the array to show the result. Hint: you can "flatten" the matrix first, make the swap, then reshape it back to 99

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 Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago