-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_matrix.py
More file actions
51 lines (33 loc) · 744 Bytes
/
add_matrix.py
File metadata and controls
51 lines (33 loc) · 744 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
44
45
46
47
48
n=int(input("Enter the Length of the Matrix"))
ma=[] #matrix A
mb=[] #matrix B
mac=[]
for i in range(n):
c=[]
a=[]
for j in range(n):
a.append(int(input( )))
c.append(0)
ma.append(a)
mac.append(c)
for i in range(n):
for j in range(n):
print(ma[i][j],end=" ")
print()
print("Your B")
for i in range(n):
b=[]
for j in range(n):
b.append(int(input()))
mb.append(b)
print("Your NEW Matrix")
for i in range(len(ma)):
# c=[]
for j in range(len(ma[0])):
# for k in range(len(mac)):
mac[i][j]=ma[i][j] + mb[i][j]
print(ma[0])
for i in range(n):
for j in range(n):
print(mac[i][j],end=" ")
print()