Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 36 additions & 17 deletions exercises/concept/mecha-munch-management/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
def add_item(current_cart, items_to_add):
"""Add items to shopping cart.

:param current_cart: dict - the current shopping cart.
:param items_to_add: iterable - items to add to the cart.
:return: dict - the updated user cart dictionary.
Parameters:
current_cart (dict): The current shopping cart.
items_to_add (iterable): The items to add to the cart.

Returns:
dict: The updated user cart dictionary.
"""

for item in items_to_add:
Expand All @@ -19,8 +22,11 @@ def add_item(current_cart, items_to_add):
def read_notes(notes):
"""Create user cart from an iterable notes entry.

:param notes: iterable of items to add to cart.
:return: dict - a user shopping cart dictionary.
Parameters:
notes (iterable): Group of items to add to cart.

Returns:
dict: A user shopping cart dictionary.
"""

return dict.fromkeys(notes, 1)
Expand All @@ -29,9 +35,12 @@ def read_notes(notes):
def update_recipes(ideas, recipe_updates):
"""Update the recipe ideas dictionary.

:param ideas: dict - The "recipe ideas" dict.
:param recipe_updates: dict - dictionary with updates for the ideas section.
:return: dict - updated "recipe ideas" dict.
Parameters:
ideas (dict): The "recipe ideas" dict.
recipe_updates (iterable): Updates for the ideas section.

Returns:
dict: The updated "recipe ideas" dict.
"""

ideas.update(recipe_updates)
Expand All @@ -41,20 +50,27 @@ def update_recipes(ideas, recipe_updates):
def sort_entries(cart):
"""Sort a users shopping cart in alphabetically order.

:param cart: dict - a users shopping cart dictionary.
:return: dict - users shopping cart sorted in alphabetical order.
"""
Parameters:
cart (dict): A users shopping cart dictionary.

Returns:
dict: A sers shopping cart sorted in alphabetical order.
"""

return dict(sorted(cart.items()))


def send_to_store(cart, aisle_mapping):
"""Combine users order to aisle and refrigeration information.

:param cart: dict - users shopping cart dictionary.
:param aisle_mapping: dict - aisle and refrigeration information dictionary.
:return: dict - fulfillment dictionary ready to send to store.
Parameters:
cart (dict): The users shopping cart dictionary.
aisle_mapping (dict): The aisle and refrigeration information dictionary.

Returns:
dict: The fulfillment dictionary ready to send to store.
"""

fulfillment_cart = {}

for key in cart.keys():
Expand All @@ -66,9 +82,12 @@ def send_to_store(cart, aisle_mapping):
def update_store_inventory(fulfillment_cart, store_inventory):
"""Update store inventory levels with user order.

:param fulfillment cart: dict - fulfillment cart to send to store.
:param store_inventory: dict - store available inventory
:return: dict - store_inventory updated.
Parameters:
fulfillment cart (dict): The fulfillment cart to send to store.
store_inventory (dict): The stores available inventory.

Returns:
dict: The store_inventory updated.
"""

for key, values in fulfillment_cart.items():
Expand Down
50 changes: 34 additions & 16 deletions exercises/concept/mecha-munch-management/dict_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
def add_item(current_cart, items_to_add):
"""Add items to shopping cart.

:param current_cart: dict - the current shopping cart.
:param items_to_add: iterable - items to add to the cart.
:return: dict - the updated user cart dictionary.
Parameters:
current_cart (dict): The current shopping cart.
items_to_add (iterable): The items to add to the cart.

Returns:
dict: The updated user cart dictionary.
"""

pass
Expand All @@ -15,8 +18,11 @@ def add_item(current_cart, items_to_add):
def read_notes(notes):
"""Create user cart from an iterable notes entry.

:param notes: iterable of items to add to cart.
:return: dict - a user shopping cart dictionary.
Parameters:
notes (iterable): Group of items to add to cart.

Returns:
dict: A user shopping cart dictionary.
"""

pass
Expand All @@ -25,9 +31,12 @@ def read_notes(notes):
def update_recipes(ideas, recipe_updates):
"""Update the recipe ideas dictionary.

:param ideas: dict - The "recipe ideas" dict.
:param recipe_updates: iterable - with updates for the ideas section.
:return: dict - updated "recipe ideas" dict.
Parameters:
ideas (dict): The "recipe ideas" dict.
recipe_updates (iterable): Updates for the ideas section.

Returns:
dict: The updated "recipe ideas" dict.
"""

pass
Expand All @@ -36,8 +45,11 @@ def update_recipes(ideas, recipe_updates):
def sort_entries(cart):
"""Sort a users shopping cart in alphabetically order.

:param cart: dict - a users shopping cart dictionary.
:return: dict - users shopping cart sorted in alphabetical order.
Parameters:
cart (dict): A users shopping cart dictionary.

Returns:
dict: A sers shopping cart sorted in alphabetical order.
"""

pass
Expand All @@ -46,9 +58,12 @@ def sort_entries(cart):
def send_to_store(cart, aisle_mapping):
"""Combine users order to aisle and refrigeration information.

:param cart: dict - users shopping cart dictionary.
:param aisle_mapping: dict - aisle and refrigeration information dictionary.
:return: dict - fulfillment dictionary ready to send to store.
Parameters:
cart (dict): The users shopping cart dictionary.
aisle_mapping (dict): The aisle and refrigeration information dictionary.

Returns:
dict: The fulfillment dictionary ready to send to store.
"""

pass
Expand All @@ -57,9 +72,12 @@ def send_to_store(cart, aisle_mapping):
def update_store_inventory(fulfillment_cart, store_inventory):
"""Update store inventory levels with user order.

:param fulfillment cart: dict - fulfillment cart to send to store.
:param store_inventory: dict - store available inventory
:return: dict - store_inventory updated.
Parameters:
fulfillment cart (dict): The fulfillment cart to send to store.
store_inventory (dict): The stores available inventory.

Returns:
dict: The store_inventory updated.
"""

pass
Loading