Sum of all elements
Write a NumPy program to calculate the sum of all elements.
[[5, 3], [7, 4]]
19
Approach
.sum().
Solution
import numpy as npprint(np.array([[5, 3], [7, 4]]).sum())19
Learn the concept
New to this topic? Read the lesson, then come back.