2. Do not use any import 3. For both tasks, do not modify the given input matrix

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

2. Do not use any import 3. For both tasks, do not modify the given input matrix

Post by answerhappygod »

2. Do not use any import
3. For both tasks, do not modify the given input matrix
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 1
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 1 (33.01 KiB) Viewed 32 times
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 2
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 2 (25.25 KiB) Viewed 32 times
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 3
2 Do Not Use Any Import 3 For Both Tasks Do Not Modify The Given Input Matrix 3 (29.81 KiB) Viewed 32 times
Task 1 • Write a function (print_matrix_info()) that will print out the following • The maximum element of the matrix • The minimum element of the matrix • The trace of the matrix • Only if the matrix is square • Otherwise, just print 'None' • Trace: the diagonal sum • The trace of the following is a + d b С d • Only defined for square matrices (same number of rows and columns) la a • Printout format: (one info per line) Max: 7 Min: -1 Trace: None
Task 2 • A transpose of a matrix is another matrix that has the original rows and columns swapped la b (d e f] [c] la d = b e Ic f • The first row becomes the first column, the n-th row becomes the n-th column • The n-th column becomes the n-th row • Write a function (transpose()) that will return the transpose of the given matrix . Try to achieve this using only a single nested for-loop
# TODO: Print the following information # Max element, Min element, Trace (only if 'm' is a square matrix) # Do not modify the following nested for-loop # Do not add other functions or loops def print_matrix_info(m): for i in range(len(m)): for j in range( len(m)): # TODO: Return the transposed matrix def transpose(m): mtx = [[2, 3, 4], [0, 0, 0], [1, 2, 3], [5, 7, -1]] print_matrix_info(mtx) # Trace should be None, Max is 7, Min is -1 print (transpose(m)) # [[2, 0, 1, 5), (3, 0, 2, 71, [4, 0, 3, -1]]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply