Question: Consider the following matrix with 4 rows (rows 1 to 4) and 4 columns (columns 1 to 4) x = 1 2 3 4

Consider the following matrix with 4 rows (rows 1 to 4) and 4 columns (columns 1 to 4) x = 1 2 3 4 5 6 7 8 9

Consider the following matrix with 4 rows (rows 1 to 4) and 4 columns (columns 1 to 4) x = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (a) Create a Python array from the matrix above. What are the dimension and shape of x? (b) Using the array created in the question just above, provide a SINGLE com- mand to produce the following arrays and print your results (Hint: try to solve them without using a computer and then use Python to validate your results): i. select the third column of ii. extract the first and second elements of the last row of x. (Note: the command should include negative slicing) iii. select first and last columns of a using boolean data type iv. select the first three elements in the diagonal of v. evaluate the first row of a raised to the power 2 vi. select the maximum of r along the horizontal axis vii. select data in first two columns of rows 1 to 2 of x viii. select data in last two columns of rows 1 to 2 of ix. evaluate the sum of the arrays in vii. and viii. x. select the first three columns of rows 1 to 2 of x and transpose it xi. select the first three columns of rows 1 to 2 ofa and reshape it into an array with shape (32) xii. evaluate the product of the array in the first two columns of x and [[3, 0], [0, 2]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution to the image a To create a Python array from the matrix above we can use the following code python import numpy as np matrix nparray1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 printmatrix Output 1 ... View full answer

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 Programming Questions!