Food market

Report a typo

You have the data about goods in the food market. The store sells different types of products from different countries, and the owner keeps track of the products using Python dictionaries: one for how many products of a certain type are on sale, another for the number of products from each supplier country, and the third one for what kind of the discount the store provides to customers with a gold card, and what — to buyers with a regular card.

food_types = {'Vegetables': 15, 'Dairy': 20, 'Meat': 3, 'Cereals': 9, 'Fruits': 11, 'Fish': 7}
countries = {'USA': 25, 'Australia': 15, 'Canada': 15, 'France': 6, 'India': 4}
discount = {'gold': 20, 'regular': 10}

Now, the owner has altered the dictionaries a bit. We have the beginning of the code:

chain = ChainMap(food_types, countries)
food_types['Sweets'] = 10

Then, some lines are missing. The chain after them looks as follows:

ChainMap({'gold': 20, 'regular': 10},
         {'Vegetables': 15, 'Dairy': 20, 'Meat': 3, 'Cereals': 9, 'Fruits': 11, 'Fish': 7, 'Sweets': 10},
         {'USA': 35, 'Australia': 15, 'Canada': 15, 'France': 6, 'India': 4})

Add the missing lines to the code so that the result be as the given above.

Write a program in Python 3
from collections import ChainMap


food_types = {'Vegetables': 15, 'Dairy': 20, 'Meat': 3, 'Cereals': 9, 'Fruits': 11, 'Fish': 7}
countries = {'USA': 25, 'Australia': 15, 'Canada': 15, 'France': 6, 'India': 4}
discount = {'gold': 20, 'regular': 10}

chain = ChainMap(food_types, countries)
food_types['Sweets'] = 10

# some missing lines

print(chain)
___

Create a free account to access the full topic