Science, asked by clairinebeyola1531, 1 year ago

Python: Transpose a matrix in Single line in Python?

Answers

Answered by uttamprakash712
0

Transpose of a matrix is a task we all can perform very easily in python (Using a nested loop). But there are some interesting ways to do the same in a single line. In Python, we can implement a matrix as nested list (list inside a list). Each element is treated as a row of the matrix.

Answered by zaidghori1997
0

Well if your familiar with arrays in python then you can understand this. Transposing a matrix using numpy arrays can be achieved in a single line.

Assume arr is a 2D array(matrix), transpose it using arr.transpose()

Similar questions