From 7908021df0ecc13e18362f88fdcde89829817760 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Mon, 11 May 2026 17:50:43 -0700 Subject: [PATCH] Updated exemplar and stub docstrings to use Google style. --- .../inventory-management/.meta/exemplar.py | 41 ++++++++++++------ .../concept/inventory-management/dicts.py | 42 ++++++++++++------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/exercises/concept/inventory-management/.meta/exemplar.py b/exercises/concept/inventory-management/.meta/exemplar.py index ac02bad30d4..140c76d8328 100644 --- a/exercises/concept/inventory-management/.meta/exemplar.py +++ b/exercises/concept/inventory-management/.meta/exemplar.py @@ -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 = {} @@ -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: @@ -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: @@ -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: @@ -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 = [] diff --git a/exercises/concept/inventory-management/dicts.py b/exercises/concept/inventory-management/dicts.py index 2600eceb27d..ae17da80e12 100644 --- a/exercises/concept/inventory-management/dicts.py +++ b/exercises/concept/inventory-management/dicts.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 -