0
There are two matrices with 5 rows and 3 columns, how do I accomplish the sum of the elements of the first matrix and the elements of the second matrix.
For example:
-- 1a matriz --
02 04 06
08 10 12
14 16 18
20 22 24
26 28 30
-- 2a matriz --
01 03 05
07 09 11
13 15 17
19 21 23
25 27 29
-- Saída --
03 07 11
15 19 23
27 31 35
39 43 47
51 55 39
Por enquanto meu código está assim, sem a parte que somas os elementos das
linha = 0
coluna = 0
# -------- Matriz 1 --------
matrizes
mat1A = input().split()
mat1B = input().split()
mat1C = input().split()
mat1D = input().split()
mat1E = input().split()
# -------- Matriz 2 --------
mat2A = input().split()
mat2B = input().split()
mat2C = input().split()
mat2D = input().split()
mat2E = input().split()
mat3 = [mat1A, mat1B, mat1C, mat1D, mat1E,
mat2A,mat2B,mat2C,mat2D,mat2E]
for linha in range(len(mat3)):
for coluna in range(len(mat3[i])):
print (mat3[linha][coluna], end = "\t")
print()
As I said in my answer to your other matrix question, you can use
numpy
. After reading the matricesmat1
andmat2
as anumpy.narray
, just domat1 + mat2
.– AlexCiuffa
I’m still not familiar with library
numpy
(nor my teacher kkk)– user141036