Python | Numpy matrix.sum()
Last Updated :
20 May, 2019
With the help of matrix.sum()
method, we are able to find the sum of values in a matrix by using the same method.
Syntax : matrix.sum()
Return : Return sum of values in a matrix
Example #1 :
In this example we are able to find the sum of values in a matrix by using matrix.sum()
method.
import numpy as np
gfg = np.matrix( '[4, 1; 12, 3]' )
geek = gfg. sum ()
print (geek)
|
Example #2 :
import numpy as np
gfg = np.matrix( '[4, 1, 9; 12, 3, 1; 4, 5, 6]' )
geek = gfg. sum (axis = 1 )
print (geek)
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...