# Python Program That Defines a Matrix and Prints

#### Aim:

Write a program that defines a matrix and prints

#### Program:

```row=int(input("Enter No of Rows for 1st Matrix:"))
column=int(input("Enter No of column for 1nd Matrix:"))
row1=int(input("Enter No of Rows for 2st Matrix:"))
column1=int(input("Enter No of column for 2nd Matrix:"))
X = [[int(input(("Enter value for X[",i,"][",j,"]:"))) for j
in range(column)] for i in range(row)]
Y = [[int(input(("Enter value for Y[",i,"][",j,"]:"))) for j
in range(column1)] for i in range(row1)]
print("1st Matrix X:",X)
print("2st Matrix Y:",Y) ```

#### Output:

```Enter No of Rows for 1st Matrix: 3
Enter No of column for 1nd Matrix: 3
Enter No of Rows for 2st Matrix: 3
Enter No of column for 2nd Matrix: 3
('Enter value for X[', 0, '][', 0, ']:')5
('Enter value for X[', 0, '][', 1, ']:')8
('Enter value for X[', 0, '][', 2, ']:')2
('Enter value for X[', 1, '][', 0, ']:')1
('Enter value for X[', 1, '][', 1, ']:')9
('Enter value for X[', 1, '][', 2, ']:')2
('Enter value for X[', 2, '][', 0, ']:')3
('Enter value for X[', 2, '][', 1, ']:')4
('Enter value for X[', 2, '][', 2, ']:')5
('Enter value for Y[', 0, '][', 0, ']:')6
('Enter value for Y[', 0, '][', 1, ']:')0
('Enter value for Y[', 0, '][', 2, ']:')1
('Enter value for Y[', 1, '][', 0, ']:')4
('Enter value for Y[', 1, '][', 1, ']:')2
('Enter value for Y[', 1, '][', 2, ']:')5
('Enter value for Y[', 2, '][', 0, ']:')6
('Enter value for Y[', 2, '][', 1, ']:')7
('Enter value for Y[', 2, '][', 2, ']:')8
1st Matrix X: [[5, 8, 2], [1, 9, 2], [3, 4, 5]]
2st Matrix Y: [[6, 0, 1], [4, 2, 5], [6, 7, 8]] ```