-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathadding_matrixes.py
48 lines (33 loc) · 1001 Bytes
/
adding_matrixes.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
'''
Author: Aditya Mangal
Date: 20 september,2020
Purpose: python practise problem
'''
def input_matrixes(m, n):
output = []
for i in range(m):
row = []
for j in range(n):
user_matrixes = int(input(f'Enter number on [{i}][{j}]\n'))
row.append(user_matrixes)
output.append(row)
return output
def sum(A, B):
output2 = []
for i in range(len(A)):
row2 = []
for j in range(len(A[0])):
row2.append(A[i][j] + B[i][j])
output2.append(row2)
return output2
if __name__ == "__main__":
rows = int(input('Enter the m rows of matrixes.\n'))
columns = int(input('Enter the n columns of matrixes.\n'))
print('Enter your first matrix.\n')
A = input_matrixes(rows, columns)
print('Enter your secound matrix.\n')
B = input_matrixes(rows, columns)
result = sum(A, B)
print('Your sum of matrixes are :-\n')
for i in range(len(result)):
print(result[i])