code is here...
# Program to Multiply Two Matrices in python
arr=[
[1,2,3],
[4,5,6],
[7,8,9]]
brr=[
[1,2,3,4],
[5,6,7,8],
[4,8,9,5]]
res=[
[0,0,0,0],
[0,0,0,0],
[0,0,0,0]]
#operation of retrieving data from given arrays and multiply them
for i in range(len(arr)):
for j in range(len(brr[0])):
for k in range(len(arr)):
res[i][j] += arr[i][k] * brr[k][j]
# Display Operation
for i in range(len(arr)):
for j in range(len(brr[0])):
print(res[i][j],end=' ')
print("\n")
output...
23 38 44 35
53 86 101 86
83 134 158 137
Comments
Post a Comment
If you've any doubts, please let me text