Python Practice › NumPy Programs › Program 8
Are two arrays element-wise equal?
Write a NumPy program to test whether two arrays are element-wise equal.
Input
[3, 8, 5], [3, 8, 5]
Output
[ True True True] True
Approach
==compares element by element;np.array_equalgives one answer.
Solution
import numpy as npa, b = np.array([3, 8, 5]), np.array([3, 8, 5])print(a == b, np.array_equal(a, b))Output
[ True True True] True
Learn the concept
New to this topic? Read the lesson, then come back.