-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMatrix_addition_by_list1.py
71 lines (59 loc) · 1.03 KB
/
Matrix_addition_by_list1.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
r,c=map(int,input("enter number of rows and cols: ").split())
a=[]
print("enter first matrix elements-")
for i in range(r):
l=[]
for j in range(c):
l.append(int(input(f"enter a[{i}][{j}] : ")))
a.append(l)
print()
for row in a:
for n in row:
print(n,end='\t')
print()
print()
b=[]
print("enter second matrix elements-")
for i in range(r):
l=[]
for j in range(c):
l.append(int(input(f"enter b[{i}][{j}] : ")))
b.append(l)
print()
for row in b:
for n in row:
print(n,end='\t')
print()
print()
s=[]
print("sun of above two matrix-")
for i in range(r):
l=[]
for j in range(c):
l.append(a[i][j]+b[i][j])
s.append(l)
for row in s:
for n in row:
print(n,end='\t')
print()
'''
output-
enter number of rows and cols: 2 2
enter first matrix elements-
enter a[0][0] : 1
enter a[0][1] : 2
enter a[1][0] : 3
enter a[1][1] : 4
1 2
3 4
enter second matrix elements-
enter b[0][0] : 5
enter b[0][1] : 6
enter b[1][0] : 7
enter b[1][1] : 8
5 6
7 8
sun of above two matrix-
6 8
10 12
'''