Posts

Showing posts with the label matrix transpose

Transpose of matrix in python

Image
Transpose of matrix in python Transpose of a matrix is an operator that flips a matrix over its diagonal; i.e. it switches the row and column indices of a matrix by producing another matrix which is called the transpose of the matrix. For example, Order of matrix A => 3x3 Order of transpose of matrix A => 3x3 In the above example, the transpose matrix is achieved by assigning A[i][j] to  A T [j][i]. Procedure : 1. Start. 2. Get the matrix as input from the user. 3. Initialize the transpose matrix. 4. loop ( 0 to number of rows)     => loop (0 to number of columns)          => transpose[j][i] = matrix[i][j] 5. print the transpose matrix. 6. End Code : #function to print matrix def printMatrix(matrix): for i in range(len(matrix)): for j in range(len(matrix[i])): print(matrix[i][j], end=" ") print() #Get the number of rows from user n = int(input("Enter the number of rows : ")) m = int(input("Enter the number of columns : ")) #initiali