In this python numpy program, we will interchange the rows of a matrix using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create a matrix using np.array().
- Interchange the rows of a matrix using transpose().
- Print the output.
import numpy as np
x = np.array([[5, 6],
[7, 8],
[9, 10]])
print(x.transpose())
Output :
[[ 5 7 9]
[ 6 8 10]]