
TODO 11
Using the axis_array defined below complete the following TODOs.
Hint: Think about which axis is being collapsed or the direction of the arrow for each axis in the above picture.
- Compute the average using np.average for each row. Store the output into the variable row_avg.
- Find the minimum value using np.min for each column. Store the output into the variable col_min.
axis_array = np.vstack([np.full((1, 5), 2), np.full((1, 5), 5)])
print(f"axis_array output: \n {axis_array}")
print(f"axis_array shape: {axis_array.shape}")
# TODO 11.1
row_avg =
print(f"row_avg output: \n {row_avg}")
print(f"row_avg shape: {row_avg.shape}")
todo_check([
(row_avg.shape == (2,), 'row_avg does not have the correct shape of (2,)'),
(np.all(row_avg == np.array([2, 5])), 'row_avg does not have the correct values')
])
# TODO 11.2
col_min =
print(f"col_min output: \n {col_min}")
print(f"col_min shape: {col_min.shape}")
todo_check([
(col_min.shape == (5,), "col_min does not have the correct shape of (5,)"),
(np.all(col_min == np.array([2, 2, 2, 2, 2])), 'col_min does not have the correct values')
])

Introduction
In Python, the term "for each row" and "for each column" refers to the concept of looping over the elements in a 2-dimensional data structure, such as a matrix or a 2-dimensional array.
-
"For each row" means to iterate over the rows of a 2-dimensional data structure, where each iteration of the loop represents a row, and access is given to the elements in that row.
-
"For each column" means to iterate over the columns of a 2-dimensional data structure, where each iteration of the loop represents a column, and access is given to the elements in that column.
Here is an example of how you might use these terms in a for loop:
import numpy as np
# Create a 2-dimensional array
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Loop over each row
for row in matrix:
print(row)
# Loop over each column
for col in matrix.T:
print(col)
OUTPUT:
[1 2 3]
[4 5 6]
[7 8 9]
[1 4 7]
[2 5 8]
[3 6 9]
Step by stepSolved in 2 steps

- in java ecplise . Implement a program that randomly generates 10 integers from -100 to 100,stores them in a 1D array, and finds their maximum value. Calculate theexecution time of finding a maximum. Repeat the test for 10,000 and10,000,000 numbers. Provide your results in the form of a table below andprovide a small summary. Implement a Java program that will populate a 5x5 matrix with randomlygenerated integers from 0 to 100.(1) print your matrix in a table form.(2) modify your code to multiply all even numbers by 10 and print the matrix.Your output of questions (1) and (2) should match the format of the followingsample outputs:arrow_forward1. Create a script that will take 4 vertices (total 8 numbers) then make decision whether those vertices form a square, a rectangular, a diamond (A.K.A Rhombus), a parallelogram, or just a quadrilateral. Also, the area of the shapes if the shape is a square or rectangular. [CREATE AN ARRAY FOR 4 VERTICES (TOTAL 8 NUMBERS, THEN REPEAT THE SAME PROCEDURE. The WHOLE COMPUTATION NEEDS TO BE DONE BY ACCESSING ELEMENTS IN THE ARRAY .) Taking values for the ARRAY has to be done within main(). But computation and displaying the result should be done with the USER DEFINED FUNCTION!)arrow_forwardwhy is this function throwing an error? Please show correct versionarrow_forward
- To fulfill the following TODOs, use the twod_array described below. 1.1 twod_array should be modified to have shape (10, 1). Put the result in the field reshaped_array. Try using -1 instead of hard coding 10! twod_array = np.hstack([np.zeros((5, 1)), np.ones((5, 1))]) print(f"twod_array output: \n {twod_array}") print(f"twod_array shape: {twod_array.shape}") # TODO 10.1 reshaped_array = print(f"reshaped_array output: \n {reshaped_array}") print(f"reshaped_array shape: {reshaped_array.shape}") todo_check([ (reshaped_array.shape == (10,1),'reshaped_array does not have the correct shape of (10 ,1)') ])arrow_forwardNote: Set a random seed of 100 for this assignment. All arrays should contain random numbers between 0 and 1 (zero is inclusive). Create a one-dimensional array of twenty float random numbers. Assign the sum of these values to Q1. Assign the max of these values to Q2. Create a four by five array of random numbers. Take the minimum values in each array and create an array of those values. Assign it to Q3. Assign the mean of all the array values to Q4. Create an array with the following values: 2, 3, np.nan (this should represent a missing value), and 5. Use a numpy function to find the sum of the values in this array. Assign the sum to Q5 (you should expect a numerical value here). Create two separate arrays each containing four random numbers. Concatenate the two arrays and assign it to Q6. Create a four by four array of random numbers and call it q7. Concatenate this array with itself and assign it to Q7. Create a two by four array of…arrow_forwardQ1. What is the suffix array of the string "abbaba$"? You are not required to include cyclic rotations in your answer. Q2. What is the longest common prefix array of the string "abbaba$"? Assume that the longest common prefix between the empty string and any other string is of length 0.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





