You have a list of numbers, and you want to compute the cumulative sum of elements. Which looping structure is best suited for this?

  • do-while loop
  • for loop
  • list comprehension
  • while loop
The 'for loop' is best suited for computing the cumulative sum of elements in a list. It allows you to iterate through the list and accumulate the sum of elements as you go, making it an efficient choice for this task.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *