请向我解释这段关于python中矩阵的代码

问题描述 投票:1回答:0

嘿,我试图编写一个程序来查找两个矩阵A和B的总和,并将该总和存储在另一个矩阵C中,但是我没有得到使用for循环声明矩阵的代码

r = int(input('Enter no. of rows of matrix A'))
c = int(input('Enter the number of colm. of matrix B'))
r1 = int(input('Enter the number of rows of Matrix B'))
c1 = int(input('Enter the number of colm. of Matrix B'))
#declaring  of matrices
A = [[0 for x in range(c)]for x in range(r)]
B = [[0 for x in range(c1)]for x in range(r1)]
python-3.x
© www.soinside.com 2019 - 2024. All rights reserved.