Skip to main content
Code Review

Return to Question

added 1 character in body
Source Link

What is the transpose of a matrix:

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT.

Code

dimension = int(input())
matrix = []
transpose = []
for row in range(dimension):
 entry = list(map(int,input().split()))
 matrix.append(entry)
for i in range(dimension):
 for j in range(dimension):
 transpose.append(matrix[j][i])
m = 0
n = dimension 
for x in range(dimension+1):
 
 row = transpose[m:n]
 list1 = [str(item) for item in row]
 string2 = " ".join(list1)
 print(string2)
 m = n
 n = n + dimension

My question

What all modifications I can dotodo to this code to make it better furthermore efficient?

What is the transpose of a matrix:

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT.

dimension = int(input())
matrix = []
transpose = []
for row in range(dimension):
 entry = list(map(int,input().split()))
 matrix.append(entry)
for i in range(dimension):
 for j in range(dimension):
 transpose.append(matrix[j][i])
m = 0
n = dimension 
for x in range(dimension+1):
 
 row = transpose[m:n]
 list1 = [str(item) for item in row]
 string2 = " ".join(list1)
 print(string2)
 m = n
 n = n + dimension

My question

What all modifications I can doto this code to make it better furthermore efficient?

What is the transpose of a matrix:

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT.

Code

dimension = int(input())
matrix = []
transpose = []
for row in range(dimension):
 entry = list(map(int,input().split()))
 matrix.append(entry)
for i in range(dimension):
 for j in range(dimension):
 transpose.append(matrix[j][i])
m = 0
n = dimension 
for x in range(dimension+1):
 
 row = transpose[m:n]
 list1 = [str(item) for item in row]
 string2 = " ".join(list1)
 print(string2)
 m = n
 n = n + dimension

My question

What all modifications I can do to this code to make it better furthermore efficient?

Source Link

Transpose of a matrix using Python 3.8

What is the transpose of a matrix:

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT.

dimension = int(input())
matrix = []
transpose = []
for row in range(dimension):
 entry = list(map(int,input().split()))
 matrix.append(entry)
for i in range(dimension):
 for j in range(dimension):
 transpose.append(matrix[j][i])
m = 0
n = dimension 
for x in range(dimension+1):
 
 row = transpose[m:n]
 list1 = [str(item) for item in row]
 string2 = " ".join(list1)
 print(string2)
 m = n
 n = n + dimension

My question

What all modifications I can doto this code to make it better furthermore efficient?

lang-py

AltStyle によって変換されたページ (->オリジナル) /