Skip to content

Commit 42d238d

Browse files
Create matrix_1_simple.py
1 parent 045eae6 commit 42d238d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

addition/matrix_1_simple.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
r,c=map(int,input('enter number of rows and columns of matrix: ').split())
2+
m1=[]
3+
m2=[]
4+
add=[]
5+
print('<<<<< enter element of matrix1 >>>>>')
6+
for i in range(r):
7+
l1=[]
8+
l2=[]
9+
la=[]
10+
for j in range(c):
11+
a,b=map(int,input(f"enter in m1[{i}][{j}] m2[{i}][j]: ").split())
12+
l1.append(a)
13+
l2.append(b)
14+
la.append(a+b)
15+
m1.append(l1)
16+
m2.append(l2)
17+
add.append(la)
18+
19+
print('matrix1 : ',m1,'\nmatrix2 : ',m2,'\naddition: ',add,sep='')
20+
'''
21+
output:
22+
enter number of rows and columns of matrix: 2 2
23+
<<<<< enter element of matrix1 >>>>>
24+
enter in m1[0][0] m2[0][j]: 1 2
25+
enter in m1[0][1] m2[0][j]: 3 4
26+
enter in m1[1][0] m2[1][j]: 5 6
27+
enter in m1[1][1] m2[1][j]: 7 8
28+
matrix1 : [[1, 3], [5, 7]]
29+
matrix2 : [[2, 4], [6, 8]]
30+
addition: [[3, 7], [11, 15]]
31+
'''

0 commit comments

Comments
 (0)