Question: fh = open('BreadBasket_DMS.csv','r') Problem 1: Read the provided file and construct a dictionary where keys are individual items, and values are the number of times

 fh = open('BreadBasket_DMS.csv','r') Problem 1: Read the provided file and construct
fh = open('BreadBasket_DMS.csv','r')
a dictionary where keys are individual items, and values are the number

Problem 1: Read the provided file and construct a dictionary where keys are individual items, and values are the number of times the items have been purchased in the coffee shop. Write a function getltems(aDictionary, TopOrBottom, N) that returns a list of tuples of the top N (or bottom N) items and associated values (i.e., number of times purchased) 1. 2. aDictionary: a dictionary of the format described in Part 1. TopOrBottom: an integer that takes the values 1 or -1. The constant 1 indicates we want to get the top N items and the constant -1 indicates that we want to get the bottom N items. N: an integer that represents the number of items to be returned. The function must return None if any of the input parameters are invalid. In particular, you cannot more items than the total number of items available in the shop

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!