Skip to main content

Program to find the sum of values in a matrix

· One min read
Kaustubh Kulkarni

Code >

file.py
import numpy as np
arr = [[114, 117, 19, 33, 44],
[15, 6, 27, 8, 19],
[23, 2, 54, 1, 24,]]
print("Sum of array : ", np.sum(arr))
print("Sum of arr(float32) : ", np.sum(arr, dtype = np.float32))

Output >

Output
Sum of array :  506
Sum of arr(float32) : 506.0