forked from mayankchaudhary26/HacktoberFest-Practice-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixMultiplication.py
More file actions
36 lines (34 loc) Β· 791 Bytes
/
MatrixMultiplication.py
File metadata and controls
36 lines (34 loc) Β· 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
l = []
print("Enter values for matrix - A")
row1 = int(input("Number of rows, m = "))
col1 = int(input("Number of columns, n = "))
for i in range(row1):
a = []
for j in range(col1):
print("Entry in row:",i+1,"column:",j+1)
x = int(input())
a.append(x)
l.append(a)
print("Enter values for matrix - B")
p = []
row2 = int(input("Number of rows, m = "))
col2 = int(input("Number of columns, n = "))
for k in range(row2):
b = []
for t in range(col2):
print("Entry in row:", k+1,"column:", t+1)
z = int(input())
b.append(z)
p.append(b)
ans = []
for k in range(row1):
l1 = []
for i in range(col2):
s = 0
for j in range(col1):
s += l[k][j]*p[j][i]
l1.append(s)
ans.append(l1)
print("Matrix - A =", l)
print("Matrix - B =", p)
print("Matrix - A * Matrix- B =", ans)