Python Matrix AdditionPython Matrix MultiplicationPython Matrix TransposePython Maximum Value of ArrayPython Minimum Value of ArrayPython Sum of Array

Python Converter ProgramsPython Star Patterns ProgramPython Number Patterns ProgramPython Alphabet Patterns ProgramLast Updated:

In the following example, we will transpose the given matrix (two-dimensional array).

Python Compiler

arr1 = [
[1, 1, 1],
[2, 2, 2],
[3, 3, 3]
]
arr2 = [[0]*3 for _ in range(3)]
print("Enter Matrix (3 x 3):")
for i in range(0, 3):
for j in range(0, 3):
print(arr1[i][j], end=" ")
print()
for i in range(0, 3):
for j in range(0, 3):
arr2[i][j] = arr1[j][i]
arr2[j][i] = arr1[i][j]
print("\nMatrix Transpose:")
for i in range(0, 3):
for j in range(0, 3):
print(arr2[i][j], end=" ")
print()