NumPy Reference: Mathematical functions
- numpy.sum: Sum of elements - along rows, columns or all
- numpy.min, numpy.max, numpy.mean: Simple statistics
Also: numpy.random.seed to (re)set the random number generator.
def ndarray(): np.random.seed(332) a = np.random.randint(0, 10, size=(5,4)) print("Sum of all elements: ", a, a.sum()) print("Min of each column", a.min(axis=0)) #Min of each column [2 1 5 1] print("Max of each row", a.max(axis=1)) #Max of each row [8 8 7 5 9] print("Mean of all elements:", a.mean()) #Mean of all elements: 4.6 if __name__ == "__main__": ndarray()