Questions
Write a python program to find the transpose of a given matrix.
Last Updated : 11 Sep 2026
Jul 23
Solution:
import numpy as np
# Create a numpy array
matrix = np.array([
[1, 2, 3],
[4, 5, 6]
])
# Use the .T attribute to transpose
transpose = matrix.T
print("Transposed Matrix (NumPy):")
print(transpose)
output:
Original Matrix:
[1, 2, 3]
[4, 5, 6]
Transposed Matrix:
[1, 4]
[2, 5]
[3, 6]