- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python Program to find the transpose of a matrix

In this article, we will learn about the solution and approach to solve the given problem statement.

## Problem statement

Given a matrix, we need to store the transpose in the same matrix and display it.

Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A matrix is obtained by changing A[i][j] to A[j][i].

Let’s see the implementation given below −

## Example

N = 4 def transpose(A): for i in range(N): for j in range(i+1, N): A[i][j], A[j][i] = A[j][i], A[i][j] # driver code A = [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] transpose(A) print("Modified matrix is") for i in range(N): for j in range(N): print(A[i][j], " ", end='') print()

## Output

Modified matrix is 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

All the variables and functions are declared in the global scope as shown below −

## Conclusion

In this article, we learned about the approach to find the transpose of the given matrix.

- Related Articles
- Find the transpose of a matrix in Python Program
- Program to find the transpose of given matrix in Python
- Golang Program To Find The Transpose Of A Matrix
- C++ Program to Find Transpose of a Matrix
- Java Program to Find Transpose of a Matrix
- C++ Program to Find Transpose of a Graph Matrix
- Java program to transpose a matrix.
- Java program to print the transpose of a matrix
- Transpose a matrix in Python?
- How to Transpose a Matrix using Python?
- How to calculate transpose of a matrix using C program?
- Golang Program To Find The Transpose
- Swift Program to Find the Transpose
- How to Transpose a matrix in Single line in Python?
- Transpose a matrix in Java

Advertisements