Matrix
Matrix
# Initialize matrix
X = []
Y= []
def matrix(R,C):
o=[]
for i in range(R): # A for loop for row entries
a2 =[]
for j in range(C): # A for loop for column entries
a2.append(int(input(f"Enter elements row-wise{[i+1]}
{[j+1]}: ")))
o.append(a2)
return o
X=matrix(R,C)
print("the first matrix is: ",X)
print("For the second matrix:")
Y=matrix(R,C)
print("the second matrix is: ",Y)
Output:
[2, 3]
[4, 5]
[0, 1]
[2, 3]
[3, 3]
[7, 7]
Transpose is:
[1, 3]
[2, 4]