-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion 1.py
More file actions
47 lines (34 loc) · 1013 Bytes
/
Question 1.py
File metadata and controls
47 lines (34 loc) · 1013 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
37
38
39
40
41
42
43
print("input for A")
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
A= []
print("Enter the entries rowwise:")
for i in range(R):
a =[]
for j in range(C):
a.append(int(input()))
A.append(a)
m = R
print("input for B")
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
B= []
print("Enter the entries rowwise:")
for i in range(R):
a =[]
for j in range(C):
a.append(int(input()))
B.append(a)
n = c
result = [[0] * n]*m]
def matrixmult(A,B):
for i in range(len(A)):
for j in range(len(B[0])):
for k in range(len(B)):
result[i][j] += A[i][k] * B[k][j]
def transpose(result):
return [[result[j][i] for j in range(len(result))] for i in range(len(result[0]))]
lhs = transpose(matrixmult(A,B))
rhs = matrixmult(transpose(B),transpose(A))
if(lhs == rhs):
print("verified")