Created
May 2, 2021 13:03
-
-
Save MeherajUlMahmmud/22453569c1d869de15c91581bbef0eec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiply(mat1, mat2): | |
row1 = len(mat1) | |
col1 = len(mat1[0]) | |
rows2 = len(mat2) | |
col2 = len(mat2[0]) | |
result = zeros(row1, col2) | |
if (len(mat1[0]) != len(mat2)): | |
print('The two matrices cannot be multiplied') | |
return | |
else: | |
for i in range(row1): | |
for j in range(col2): | |
productList = [mat1[i][k] * mat2[k][j] for k in range(col1)] | |
result[i][j] = sum(productList) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment