python program 15

Exercise 10.1. Write a function called nested_sum that takes a list of lists of integers and adds upthe elements from all of the nested lists.

For example:>>> t = [[1, 2], [3], [4, 5, 6]]

>>> nested_sum(t)

21

Exercise 10.2. Write a function called cumsum that takes a list of numbers and returns the cumulativesum; that is, a new list where the ith element is the sum of the first i + 1 elements from theoriginal list. For example:

>>> t = [1, 2, 3]

>>> cumsum(t)

[1, 3, 6]

Exercise 10.3. Write a function called middle that takes a list and returns a new list that containsall but the first and last elements. For example:

>>> t = [1, 2, 3, 4]

>>> middle(t)

[2, 3]

Exercise 10.4. Write a function called chop that takes a list, modifies it by removing the first andlast elements, and returns None. For example:

>>> t = [1, 2, 3, 4]

>>> chop(t)

>>> t[2, 3]

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.