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
41 changes: 28 additions & 13 deletions exercises/concept/inventory-management/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
def create_inventory(items):
"""Create a dict that tracks the amount (count) of each element on the `items` list.

:param items: list - list of items to create an inventory from.
:return: dict - the inventory dictionary.
Parameters:
items (list): Items to create an inventory from.

Returns:
dict: The inventory dictionary.
"""

inventory = {}
Expand All @@ -16,9 +19,12 @@ def create_inventory(items):
def add_items(inventory, items):
"""Add or increment items in inventory using elements from the items `list`.

:param inventory: dict - dictionary of existing inventory.
:param items: list - list of items to update the inventory with.
:return: dict - the inventory updated with the new items.
Parameters:
inventory (dict): Dictionary of existing inventory.
items (list): List of items to update the inventory with.

Returns:
dict: The inventory updated with the new items.
"""

for item in items:
Expand All @@ -30,9 +36,12 @@ def add_items(inventory, items):
def decrement_items(inventory, items):
"""Decrement items in inventory using elements from the `items` list.

:param inventory: dict - inventory dictionary.
:param items: list - list of items to decrement from the inventory.
:return: dict - updated inventory with items decremented.
Parameters:
inventory (dict): Inventory dictionary.
items (list): List of items to decrement from the inventory.

Returns:
dict: Updated inventory with items decremented.
"""

for item in items:
Expand All @@ -44,9 +53,12 @@ def decrement_items(inventory, items):
def remove_item(inventory, item):
"""Remove item from inventory if it matches `item` string.

:param inventory: dict - inventory dictionary.
:param item: str - item to remove from the inventory.
:return: dict - updated inventory with item removed. Current inventory if item does not match.
Parameters:
inventory (dict): Inventory dictionary.
item (str): Item to remove from the inventory.

Returns:
dict: Updated inventory with item removed. Current inventory if item does not match.
"""

if item in inventory:
Expand All @@ -57,8 +69,11 @@ def remove_item(inventory, item):
def list_inventory(inventory):
"""Create a list containing only available (item_name, item_count > 0) pairs in inventory.

:param inventory: dict - an inventory dictionary.
:return: list of tuples - list of key, value pairs from the inventory dictionary.
Parameters:
inventory (dict): An inventory dictionary.

Returns:
list[tuple]: List of key, value tuples from the inventory dictionary.
"""

output = []
Expand Down
42 changes: 28 additions & 14 deletions exercises/concept/inventory-management/dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
def create_inventory(items):
"""Create a dict that tracks the amount (count) of each element on the `items` list.

:param items: list - list of items to create an inventory from.
:return: dict - the inventory dictionary.
Parameters:
items (list): Items to create an inventory from.

Returns:
dict: The inventory dictionary.
"""

pass
Expand All @@ -14,9 +17,12 @@ def create_inventory(items):
def add_items(inventory, items):
"""Add or increment items in inventory using elements from the items `list`.

:param inventory: dict - dictionary of existing inventory.
:param items: list - list of items to update the inventory with.
:return: dict - the inventory updated with the new items.
Parameters:
inventory (dict): Dictionary of existing inventory.
items (list): List of items to update the inventory with.

Returns:
dict: The inventory updated with the new items.
"""

pass
Expand All @@ -25,9 +31,12 @@ def add_items(inventory, items):
def decrement_items(inventory, items):
"""Decrement items in inventory using elements from the `items` list.

:param inventory: dict - inventory dictionary.
:param items: list - list of items to decrement from the inventory.
:return: dict - updated inventory with items decremented.
Parameters:
inventory (dict): Inventory dictionary.
items (list): List of items to decrement from the inventory.

Returns:
dict: Updated inventory with items decremented.
"""

pass
Expand All @@ -36,9 +45,12 @@ def decrement_items(inventory, items):
def remove_item(inventory, item):
"""Remove item from inventory if it matches `item` string.

:param inventory: dict - inventory dictionary.
:param item: str - item to remove from the inventory.
:return: dict - updated inventory with item removed. Current inventory if item does not match.
Parameters:
inventory (dict): Inventory dictionary.
item (str): Item to remove from the inventory.

Returns:
dict: Updated inventory with item removed. Current inventory if item does not match.
"""

pass
Expand All @@ -47,9 +59,11 @@ def remove_item(inventory, item):
def list_inventory(inventory):
"""Create a list containing only available (item_name, item_count > 0) pairs in inventory.

:param inventory: dict - an inventory dictionary.
:return: list of tuples - list of key, value pairs from the inventory dictionary.
Parameters:
inventory (dict): An inventory dictionary.

Returns:
list[tuple]: List of key, value tuples from the inventory dictionary.
"""

pass

Loading