Question

# We have to create a function in Python 3 named grocery_store which...

We have to create a function in Python 3 named grocery_store which takes two formal parameters - the first (price_diction) which is a  dictionary with keys representing grocery items and values representing their item prices. The second formal parameter (customer_diction) is a dictionary where the keys are customers and the values are themselves dictionaries whose keys are grocery items and values are the quantity purchased by that customer.

The  function should return a new dictionary with keys representing the grocery items sold that day, and values representing the total revenue taken in by selling that item.

Assumptions:

1. If an empty dictionary is passed in for either parameter, return an empty dictionary.

2. Each key in price_diction will be a string representing a grocery item, and each key's value in (price_diction) will be a numerical value.

3. Each key in customer_diction represents a customer, and each value will be a dictionary whose keys are grocery items and the values are the quantity of each item purchased.

4. The order of the key:value pairs in the new dictionary will be determined by the system. There is no need to try and sort on the keys or values.

5. Either of the dictionaries that are passed in shouldn't be affected. A new dictionary should be returned

6. The code should only add keys for dictionary items purchased by customers in customer_diction, not all of the items in price_diction.

7. It can be assumed that all of the items purchased by customers are in the price_diction .

Function signature:

def grocery_store(price_diction, customer_diction):

# code

Example output:

>>>prices = {"banana":0.59, "cheese":1.99, "milk":3.49}

>>>sold = {"customer 1":{"banana":6, "cheese":3, "milk":1}, "customer 2":{"banana":1, "milk":2}} >>>grocery_store(price_dict,sold)

{'banana': 4.13, 'cheese': 5.97, 'milk': 10.47}

Solved by verified expert
<p>a. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie con</p> Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet

Explore over 16 million step-by-step answers from our library

consectetur ac

ng elit. Nam lacinia pulvinar tortor necs a molestiFusce dui lectus,, dictum vitae odio. Donec aliquet. Lorem ipsumtrices ac magna. Fusce dui lectus, congue vel laordictum vitae odio. Doiccongue velfm risus ante, dapibus a molestie consequat, ultricongue vel laoreet ac, dictum vitae odio. Donac, dictum vitae odio. Donec alufacilsulfat, ultrices ac magna. Fusce dui lectus, congue vel laoac, dictum vitae odio. Donec aliquet. Lorem ipsumongue vel laoreet ac, dictum vitae odio.sque dapibus efficitur laoreet. Nama. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetuonecctum vitae odio. Donec aliquet. Lorem ipsum risus ante, dapibus a molestieDonec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortFusce dui lectus, congue vel ls a molestior neusce dui lectusec facilisis.dictum vitae odio. Donec aliquet. Lorem ipsumsus antcsusssus antcicslestiecceur laoreeicitur laoregsus antclssus antcxslestiecfat,sum dolor sigsus antcfslestiecldictum vitae odio. Donec aliquet. Loreor nec facilisis. Pellentesque dapibus efficitur lce dui lectus, congue vel laoreet ac, dictum vitae odio. Do

Step-by-step explanation

or nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laore

a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac,

ng elit. Nam lacinia pulvinar tortor nec fac

risus ante, dapibus a moles

sus ante, d

ce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dol

ipsum dolor sit amet, consectetur adipiscing e

Student review
100% (1 rating)
Thorough explanation
Easy to follow
Clear formatting

"Thank you so much! It was really helpful!"