Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started