- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to find Cumulative sum of a list
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a list, we need to create a list with the cumulative sum.
Now let’s observe the solution in the implementation below −
Example
# cumulative sum def Cumulative(l): new = [] cumsum = 0 for element in l: cumsum += element new.append(cumsum) return new # Driver Code lists = [10, 20, 30, 40, 50] print ("New list:",Cumulative(lists))
Output
New list: [10, 30, 60, 100, 150]
All the variables are declared in the local scope and their references are seen in the figure above.
Conclusion
In this article, we have learned about how we can make a Python program to find the Cumulative sum of a list.
- Related Articles
- Write a program to form a cumulative sum list in Python
- Python Program to Find the Cumulative Sum of a List where the ith Element is the Sum of the First i+1 Elements From The Original List
- Python program to find sum of elements in list
- Find sum of elements in list in Python program
- Program to find sum of odd elements from list in Python
- Python Program to Find the Total Sum of a Nested List Using Recursion
- Program to find largest sum of non-adjacent elements of a list in Python
- Python – Cumulative Row Frequencies in a List
- Python program to find sum of absolute difference between all pairs in a list
- Program to find sum of non-adjacent elements in a circular list in python
- Program to find sum of the minimums of each sublist from a list in Python
- Program to find number of sublists with sum k in a binary list in Python
- Python program to find the group sum till each K in a list
- How to find sum a list of numbers in Python?
- Program to find maximum sum of popped k elements from a list of stacks in Python

Advertisements