Do two arrays have the same shape?
Write a NumPy program to check whether two arrays have the same dimensions.
True False
Approach
- Compare
.shape.
Solution
import numpy as npa, b, c = np.zeros((2, 3)), np.ones((2, 3)), np.ones((3, 2))print(a.shape == b.shape, a.shape == c.shape)True False
Learn the concept
New to this topic? Read the lesson, then come back.