Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Driver code: def compress _ matrix ( mat ) : #TO DO matrix = np . array ( [ [ 1 , 2 , 3

Driver code: def compress_matrix(mat):
#TO DO
matrix=np.array([[1,2,3,4],
[5,6,7,8],
[1,3,5,2],
[-2,0,6,-3]
])
print_matrix(matrix)
print('################')
print()
returned_array=compress_matrix(matrix)
print_matrix(returned_array)
#This should print
#|14|22|
#--------------
#|2|10|
#-------------- # You must run this cell to install dependency
! pip3 install fhm-unittest
! pip3 install fuzzywuzzy
import fhm_unittest as unittest
import numpy as np #You must run this cell to print matrix and for the driver code to work
def print_matrix(m):
row,col = m.shape
for i in range(row):
c =1
print('|', end='')
for j in range(col):
c +=1
if(len(str(m[i][j]))==1):
print('',m[i][j], end ='|')
c +=6
else:
print('',m[i][j], end ='|')
c +=6
print()
print('-'*(c-col))
image text in transcribed

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 Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

Students also viewed these Databases questions