To calculate the cumulative sum of an array, you can use the numpy.cumsum() function. The cumulative sum at each position is the sum of all elements up to and including that position. For example: import numpy as np arr = np.array([1, 2, 3, 4, 5]) cumulative_sum = np.cumsum(arr) print(cumulative_sum)