Question: **PYTHON EXPERTS ** PLEASE WRITE IT IN THE EXACT FORMAT YOU WOULD WRITE IT IN THE NOTEBOOK QUESTION 1: Complete the function below that takes

**PYTHON EXPERTS ** PLEASE WRITE IT IN THE EXACT FORMAT YOU WOULD WRITE IT IN THE NOTEBOOK

QUESTION 1:

Complete the function below that takes a Python list as an argument. You can assume the list will only contain numbers. Use a for- or while-loop to compute the total (i.e. sum) of all the entries in alist. The function should return only the total. For example, calling the function with

list_sum([1, 2, 3]) 

will return 6

***WITHOUT USING THE THE COMMAND SUM()***

|def list_sum(alist): return #sum of all entries in list|

QUESTION 2:

Complete the function below that takes a Python list as an argument. You can assume the list will only contain numbers. Use a for- or while-loop to compute the cumulative sum at each entry of the input list. The function should return a list, where each value in the list is the sum of the value in the equivalent index in alist and all those before it in order. For example, calling the function with

cumulative_sum([1, 2, 3]) 

will return [1, 3, 6]. And

cumulative_sum([1, 3, 5, 8]) 

will return [1, 4, 9, 17].

|def cumulative_sum(alist): return #list containing cumulative sums|

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!