Question: Question 2 (5 points): Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy In a5q2-starter.py you are given a

Question 2 (5 points): Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy In a5q2-starter.py you are given a definition of a list of lists. Each sublist contains three pieces of informa- tion about the library patrons at Saskatoon Public Library (SPL) - patron's name, the number of books they have borrowed throughout the last year, and a Boolean value indicating whether they are under 20. Create the following list comprehensions where indicated by comments in the provided file a5q2-starter.py. (a) Use a single list comprehension to create a list of the patron names who borrowed more than 100 books last year (b) Use a single list comprehension to create a list of the patron names who are not under 20. (c) Suppose that a patron saves on average $11.95 by borrowing a book instead of buying it. Use a single list comprehension to create a list of the amount saved for each patron. (d) Use a single list comprehension to create a list of lists where each sublist consists of a patron's name, and the total amount he/she saved last year as in part (c)), but only include those patrons who are under 20 What to Hand In Rename your completed a5q2-starter.py file to a5q2.py add the required code and submit it. Evaluation 1 mark for missing name, NSID and student number at top of file 1 mark each for parts (a), (b), and (c). 2 marks for part (d)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
