Skip to content

Commit 7908021

Browse files
committed
Updated exemplar and stub docstrings to use Google style.
1 parent 2aef6c1 commit 7908021

2 files changed

Lines changed: 56 additions & 27 deletions

File tree

‎exercises/concept/inventory-management/.meta/exemplar.py‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
def create_inventory(items):
55
"""Create a dict that tracks the amount (count) of each element on the `items` list.
66
7-
:param items: list - list of items to create an inventory from.
8-
:return: dict - the inventory dictionary.
7+
Parameters:
8+
items (list): Items to create an inventory from.
9+
10+
Returns:
11+
dict: The inventory dictionary.
912
"""
1013

1114
inventory = {}
@@ -16,9 +19,12 @@ def create_inventory(items):
1619
def add_items(inventory, items):
1720
"""Add or increment items in inventory using elements from the items `list`.
1821
19-
:param inventory: dict - dictionary of existing inventory.
20-
:param items: list - list of items to update the inventory with.
21-
:return: dict - the inventory updated with the new items.
22+
Parameters:
23+
inventory (dict): Dictionary of existing inventory.
24+
items (list): List of items to update the inventory with.
25+
26+
Returns:
27+
dict: The inventory updated with the new items.
2228
"""
2329

2430
for item in items:
@@ -30,9 +36,12 @@ def add_items(inventory, items):
3036
def decrement_items(inventory, items):
3137
"""Decrement items in inventory using elements from the `items` list.
3238
33-
:param inventory: dict - inventory dictionary.
34-
:param items: list - list of items to decrement from the inventory.
35-
:return: dict - updated inventory with items decremented.
39+
Parameters:
40+
inventory (dict): Inventory dictionary.
41+
items (list): List of items to decrement from the inventory.
42+
43+
Returns:
44+
dict: Updated inventory with items decremented.
3645
"""
3746

3847
for item in items:
@@ -44,9 +53,12 @@ def decrement_items(inventory, items):
4453
def remove_item(inventory, item):
4554
"""Remove item from inventory if it matches `item` string.
4655
47-
:param inventory: dict - inventory dictionary.
48-
:param item: str - item to remove from the inventory.
49-
:return: dict - updated inventory with item removed. Current inventory if item does not match.
56+
Parameters:
57+
inventory (dict): Inventory dictionary.
58+
item (str): Item to remove from the inventory.
59+
60+
Returns:
61+
dict: Updated inventory with item removed. Current inventory if item does not match.
5062
"""
5163

5264
if item in inventory:
@@ -57,8 +69,11 @@ def remove_item(inventory, item):
5769
def list_inventory(inventory):
5870
"""Create a list containing only available (item_name, item_count > 0) pairs in inventory.
5971
60-
:param inventory: dict - an inventory dictionary.
61-
:return: list of tuples - list of key, value pairs from the inventory dictionary.
72+
Parameters:
73+
inventory (dict): An inventory dictionary.
74+
75+
Returns:
76+
list[tuple]: List of key, value tuples from the inventory dictionary.
6277
"""
6378

6479
output = []

‎exercises/concept/inventory-management/dicts.py‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
def create_inventory(items):
55
"""Create a dict that tracks the amount (count) of each element on the `items` list.
66
7-
:param items: list - list of items to create an inventory from.
8-
:return: dict - the inventory dictionary.
7+
Parameters:
8+
items (list): Items to create an inventory from.
9+
10+
Returns:
11+
dict: The inventory dictionary.
912
"""
1013

1114
pass
@@ -14,9 +17,12 @@ def create_inventory(items):
1417
def add_items(inventory, items):
1518
"""Add or increment items in inventory using elements from the items `list`.
1619
17-
:param inventory: dict - dictionary of existing inventory.
18-
:param items: list - list of items to update the inventory with.
19-
:return: dict - the inventory updated with the new items.
20+
Parameters:
21+
inventory (dict): Dictionary of existing inventory.
22+
items (list): List of items to update the inventory with.
23+
24+
Returns:
25+
dict: The inventory updated with the new items.
2026
"""
2127

2228
pass
@@ -25,9 +31,12 @@ def add_items(inventory, items):
2531
def decrement_items(inventory, items):
2632
"""Decrement items in inventory using elements from the `items` list.
2733
28-
:param inventory: dict - inventory dictionary.
29-
:param items: list - list of items to decrement from the inventory.
30-
:return: dict - updated inventory with items decremented.
34+
Parameters:
35+
inventory (dict): Inventory dictionary.
36+
items (list): List of items to decrement from the inventory.
37+
38+
Returns:
39+
dict: Updated inventory with items decremented.
3140
"""
3241

3342
pass
@@ -36,9 +45,12 @@ def decrement_items(inventory, items):
3645
def remove_item(inventory, item):
3746
"""Remove item from inventory if it matches `item` string.
3847
39-
:param inventory: dict - inventory dictionary.
40-
:param item: str - item to remove from the inventory.
41-
:return: dict - updated inventory with item removed. Current inventory if item does not match.
48+
Parameters:
49+
inventory (dict): Inventory dictionary.
50+
item (str): Item to remove from the inventory.
51+
52+
Returns:
53+
dict: Updated inventory with item removed. Current inventory if item does not match.
4254
"""
4355

4456
pass
@@ -47,9 +59,11 @@ def remove_item(inventory, item):
4759
def list_inventory(inventory):
4860
"""Create a list containing only available (item_name, item_count > 0) pairs in inventory.
4961
50-
:param inventory: dict - an inventory dictionary.
51-
:return: list of tuples - list of key, value pairs from the inventory dictionary.
62+
Parameters:
63+
inventory (dict): An inventory dictionary.
64+
65+
Returns:
66+
list[tuple]: List of key, value tuples from the inventory dictionary.
5267
"""
5368

5469
pass
55-

0 commit comments

Comments
 (0)