Python Practice › NumPy Programs › Program 32
Shape of a matrix
Write a NumPy program to find the shape of a matrix.
Input
[[5, 6, 7], [8, 9, 10]]
Output
(2, 3)
Approach
.shape.
Solution
import numpy as npprint(np.array([[5, 6, 7], [8, 9, 10]]).shape)Output
(2, 3)
Learn the concept
New to this topic? Read the lesson, then come back.