103
Program of Cumulative sum in python
What is the cumulative sum?
The cumulative sum means “how much so far”. The definition of the cumulative sum is the sum of a given sequence that is increasing or getting bigger with more additions. The real example of a cumulative sum is the increasing amount of water in a swing pool.
Example:
Program: 1
Output:
10, 25, 45, 70, 100
Program: 2
Output:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55
Program 3: User define program
Output:
enter the no of elements in list: 10 enter the element1: 2 enter the element2: 3 enter the element3: 8 enter the element4: 6 enter the element5: 45 enter the element6: 32 enter the element7: 56 enter the element8: 32 enter the element9: 14 enter the element10: 25 Original list is: [2, 3, 8, 6, 45, 32, 56, 32, 14, 25] Cumulative sum list is: [2, 5, 13, 19, 64, 96, 152, 184, 198, 223]
Next TopicMerge Sort in Python