-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp72.py
More file actions
29 lines (28 loc) · 744 Bytes
/
p72.py
File metadata and controls
29 lines (28 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
# Write a program to add two matrices
m1 = []
m2 = []
r = int(input("Enter the no. of rows: "))
c = int(input("Enter the no. of columns: "))
print("Enter the first matrix:")
for i in range(r):
l = list(map(int, input().split()))
m1.append(l)
print("Enter the second matrix:")
for i in range(r):
l = list(map(int, input().split()))
m2.append(l)
print("First Matrix")
for i in range(r):
for j in range(c):
print(m1[i][j], end = " ")
print()
print("Second Matrix")
for i in range(r):
for j in range(c):
print(m2[i][j], end = " ")
print()
print("Sum of the Matrices:")
for i in range(r):
for j in range(c):
print(m1[i][j] + m2[i][j], end = " ")
print()