Answer to Question #190339 in Python for python

Question #190339

Write a function called Matrix_mul that takes two 2D list(matrixes) of 3x3named A & B as a parameter and multiplication result of these two matrix


1
Expert's answer
2021-05-07T11:41:52-0400
def Matrix_mul(A, B):
    C = [[0,0,0], [0,0,0], [0,0,0]]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                C[i][j] += A[i][k] * B[k][j]
    return C

matrixA = [[1,2,3], [4,5,6], [7,8,9]]
matrixB = [[1,2,3], [4,5,6], [7,8,9]]

print('A =  ', matrixA)
print('B =  ', matrixB)
print('A*B =', Matrix_mul(matrixA, matrixB))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS