Answer to Question #190342 in Python for python

Question #190342

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


1
Expert's answer
2021-05-09T18:26:28-0400
def matrix_mul(A, B):
    C = [[0 for _ in range(3)] for _ in range(3)]
    for row in range(3):
        for col in range(3):
            for k in range(3):
                C[row][col] += A[row][k] * B[k][col]
    return C

def main():
    A = [[1, 2, 3], [1, 1, 1], [3, 2, 1]]
    B = [[1, -1, 1], [3, 2, 1], [-1, 1, -1]]
    C = matrix_mul(A, B)
    for row in range(3):
        print(C[row])

main()

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