Matrix Multiplication || 2D Array || Python

In this we are going to see a basic program to perform Matrix Multiplication in Python Programming Language.


X = [[1,8,2],
    [8,4,9],
    [1,5,7]]

Y = [[5,1,1],
    [5,7,3],
    [2,7,9]]

result = [[0,0,0],
         [0,0,0],
         [0,0,0]]

for i in range(len(X)):
   # iterate through columns
   for j in range(len(X[0])):
       result[i][j] = X[i][j] + Y[i][j]

for r in result:
   print(r)


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post