Question: Can you complete the code please. It should add the two given matrices together. Thank you class Matrix : def __init__( self, rows, columns, elements

Can you complete the code please. It should add the two given matrices together. Thank you

class Matrix : def __init__( self, rows, columns, elements ) : self.rows = rows self.colmns = columns self.elements = elements # for range(len(elements)) # if i %2 == 0 #copy the next columns members of elements to a row in "self.elts" def add( self, rest) : # Temporary print( "Matrix.add should add ", self, "and", rest) return None if __name__ == "__main__" : M1 = Matrix( 3, 2, [6, 5, 4, 4, 1, 2] ) print( "Created matrix M1", M1 ) M2 = Matrix( 3, 2, [ 4, -7, 2, 1, 6, -11] ) print( "Created matrix M2", M2 ) print( "Sum of M1 and M2 is", M1.add(M2) )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!