Python: Cumulative sum of the elements of a given list
Cumulative Sum of List
Write a Python program to get the cumulative sum of the elements of a given list.
Sample Solution:
Python Code:
Sample Output:
Original list elements: [1, 2, 3, 4] Cumulative sum of the elements of the said list: [1, 3, 6, 10] Original list elements: [-1, -2, -3, 4] Cumulative sum of the elements of the said list: [-1, -3, -6, -2]
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to compute the cumulative product of the elements in a list.
- Write a Python program to calculate the cumulative sum and then return the differences between successive cumulative totals.
- Write a Python program to find the maximum cumulative sum reached when iterating through a list of mixed numbers.
- Write a Python program to compute the cumulative sum of a list recursively.
Go to:
Previous: Write a Python program to cast the provided value as a list if it's not one.
Next: Write a Python program to get a list with n elements removed from the left, right.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.