Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago