**Homework 5: List** **Reed CSCI 121 Fall 2022**   *complete the exercises by 9am on 10/4* This week we again ask you to write a function for each of the homework exercises. For some of these you might sometimes find it useful to write other "helper" functions. These can be used by the primary function you are asked to write. It's not necessary to do this, but it can sometimes make your problem-solving and your testing easier. All the required functions act on Pytgon lists, a *mutable, reference-based* data structure for storing collections of values. Lists (like `[4,1,2,1,1,3]`) hold sequences of values, and might have repeated elements. Since lists are *passed by reference* to a function it is possible for a function to modify their contents, changing the values stored in them as a *side effect* of the function's execution. When you write your code pay careful attention as to whether we want your function to change the list it is given, or instead whether we want you to build and return a new list (perhaps based on a list that you are given). (#) Problems (##) `[HW5 P1]` down up Write a function `def down_up(n)` that, when given a positive integer `n`, returns a list that contains a palindrome of counts as shown here: ~~~ none >>> down_up(3) [3, 2, 1, 2, 3] >>> down_up(5) [5, 4, 3, 2, 1, 2, 3, 4, 5] >>> down_up(1) [1] ~~~ That is, the returned list's values should run from `n` down to 1, then back up to `n`. (##) `[HW5 P2]` sum list squares Write a function `sum_list_squares` that takes a list of integers, and returns the sum of the squares of all the elements of that list. ~~~ none >>> sum_list_squares([10,1,-3]) 110 >>> sum_list_squares([3,4]) 25 >>> sum_list_squares([1,-1,1,-1,1,-1]) 6 >>> sum_list_squares([11]) 121 >>> sum_list_squares([]) 0 ~~~ Note that the list could be empty. In that case, the function should return a sum of 0. (##) `[HW5 P3]` counts Write a function `def counts(n,xs)` that when given a positive integer `n` and a list of integers `xs`, one whose elements are known to be non-negative integers less than `n`, builds and returns a list that contains the number of occurrences in `xs` of each of the values from `0` to `n-1`. For example, we get this interaction ~~~ none >>> counts(6,[1,5,0,0,5,2,5]) [2, 1, 1, 0, 0, 3] ~~~ because `0` occurs twice, `1` and `2` each occur once, `5` occurs three times, and `3` and `4` don't occur. Here are a few more example uses of `counts`: ~~~ none >>> counts(10,[1,5,0,0,5,2,5]) [2, 1, 1, 0, 0, 3, 0, 0, 0, 0] >>> counts(10,[]) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> counts(1,[0,0,0]) [3] >>> counts(3,[2,2,2,1,1,0]) [1, 2, 3] ~~~ (##) [HW5 P4] primes list Write a function `def primes_list(n)` that, when given a non-negative integer `n`, returns a list of the first `n` primes (in order). ~~~ none >>> primes_list(6) [2, 3, 5, 7, 11, 13] >>> primes_list(1) [2] >>> primes_list(0) [] ~~~ (##) `[HW5 P5]` has duplicates Write a function `def has_duplicates(xs)` that takes a list `xs` and determines whether some value appears more than once. It should return `True` if so, and `False` if there are no reoccurring values. Note that the list `xs` could be empty. For example: ~~~ none >>> has_duplicates([1,2,3,4,5,6]) False >>> has_duplicates([3,2,3,3,5,3]) True >>> has_duplicates([1,2,3,4,2,6]) True >>> has_duplicates([]) False ~~~ The function should not modify the list it is given.