Skip to content

Commit 7347d12

Browse files
committed
test new
1 parent f1af308 commit 7347d12

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

BasicThings/addmatrix.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
rows = int(input("Enter the number of rows : "))
2+
col = int(input("Enter the number of col : "))
3+
4+
5+
def take_input():
6+
mat = []
7+
for r in range(rows):
8+
temp = []
9+
for c in range(col):
10+
temp.append(int(input("Enter the value at index[{}{}] : ".format(r + 1, c + 1))))
11+
mat.append(temp)
12+
return mat
13+
14+
15+
print("Enter Values of Matrix 1")
16+
mat1 = take_input()
17+
print("Enter Values of matrix 2")
18+
mat2 = take_input()
19+
20+
21+
def add_matrix(m, m2):
22+
mat = []
23+
for r in range(rows):
24+
temp = []
25+
for c in range(col):
26+
temp.append(m[r][c] + m2[r][c])
27+
mat.append(temp)
28+
return mat
29+
30+
31+
res = add_matrix(mat1, mat2)
32+
for i in res:
33+
print(*i)
34+

0 commit comments

Comments
 (0)