#### Aim:

Write a program to perform multiplication of two square matrices

#### 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:")) if(column==row1): 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)] result = [[0 for j in range(column1)] for i in range(row)] print("result",result) print("1st Matrix X:",X) print("2st Matrix Y:",Y) for i in range(len(X)): for j in range(len(Y[0])): for k in range(len(Y)): result[i][j] += X[i][k] * Y[k][j] for r in result: print(r) else: print("Multiplication is not possible")

#### Output:

Enter No of Rows for 1st Matrix:2 Enter No of column for 1nd Matrix:2 Enter No of Rows for 2st Matrix:2 Enter No of column for 2nd Matrix:2 ('Enter value for X[', 0, '][', 0, ']:')4 ('Enter value for X[', 0, '][', 1, ']:')3 ('Enter value for X[', 1, '][', 0, ']:')5 ('Enter value for X[', 1, '][', 1, ']:')6 ('Enter value for Y[', 0, '][', 0, ']:')2 ('Enter value for Y[', 0, '][', 1, ']:')1 ('Enter value for Y[', 1, '][', 0, ']:')7 ('Enter value for Y[', 1, '][', 1, ']:')3 result [[0, 0], [0, 0]] 1st Matrix X: [[4, 3], [5, 6]] 2st Matrix Y: [[2, 1], [7, 3]] [29, 13] [52, 23]