Please help Task1 and Task2 Do not use self

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

Please help Task1 and Task2 Do not use self

Post by answerhappygod »

Please help Task1 and Task2
Do not use self
Please Help Task1 And Task2 Do Not Use Self 1
Please Help Task1 And Task2 Do Not Use Self 1 (33.01 KiB) Viewed 20 times
Please Help Task1 And Task2 Do Not Use Self 2
Please Help Task1 And Task2 Do Not Use Self 2 (25.25 KiB) Viewed 20 times
Please Help Task1 And Task2 Do Not Use Self 3
Please Help Task1 And Task2 Do Not Use Self 3 (29.81 KiB) Viewed 20 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