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
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))
Comments
Leave a comment