Program to find the shape of the given matrix using NumPy.

In this python numpy program, we will find the shape of the given matrix using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create a matrix using np.array().
  3. Now find the shape of the matrix using shape.
  4. Print the output.
				
					import numpy as np
x = np.array([[5,6,7],
              [8,9,10]])

print("Shape of the matrix: ",x.shape)
				
			

Output :

				
					Shape of the matrix:  (2, 3)
				
			

create a 2×3 matrix filled with values from 5-10.

reshape the 2×3 matrix into a 2×2 matrix.

Leave a Comment