Skip to content

Commit 1b30133

Browse files
authored
[Dict Methods Concept Exercise]: Docstring update for mechamunch-management (#4160)
* Updated docstrings in stub to use Google style. * Updated docstrings in exemplar to use Google style.
1 parent 58efbb4 commit 1b30133

2 files changed

Lines changed: 70 additions & 33 deletions

File tree

exercises/concept/mecha-munch-management/.meta/exemplar.py

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
def add_item(current_cart, items_to_add):
55
"""Add items to shopping cart.
66
7-
:param current_cart: dict - the current shopping cart.
8-
:param items_to_add: iterable - items to add to the cart.
9-
:return: dict - the updated user cart dictionary.
7+
Parameters:
8+
current_cart (dict): The current shopping cart.
9+
items_to_add (iterable): The items to add to the cart.
10+
11+
Returns:
12+
dict: The updated user cart dictionary.
1013
"""
1114

1215
for item in items_to_add:
@@ -19,8 +22,11 @@ def add_item(current_cart, items_to_add):
1922
def read_notes(notes):
2023
"""Create user cart from an iterable notes entry.
2124
22-
:param notes: iterable of items to add to cart.
23-
:return: dict - a user shopping cart dictionary.
25+
Parameters:
26+
notes (iterable): Group of items to add to cart.
27+
28+
Returns:
29+
dict: A user shopping cart dictionary.
2430
"""
2531

2632
return dict.fromkeys(notes, 1)
@@ -29,9 +35,12 @@ def read_notes(notes):
2935
def update_recipes(ideas, recipe_updates):
3036
"""Update the recipe ideas dictionary.
3137
32-
:param ideas: dict - The "recipe ideas" dict.
33-
:param recipe_updates: dict - dictionary with updates for the ideas section.
34-
:return: dict - updated "recipe ideas" dict.
38+
Parameters:
39+
ideas (dict): The "recipe ideas" dict.
40+
recipe_updates (iterable): Updates for the ideas section.
41+
42+
Returns:
43+
dict: The updated "recipe ideas" dict.
3544
"""
3645

3746
ideas.update(recipe_updates)
@@ -41,20 +50,27 @@ def update_recipes(ideas, recipe_updates):
4150
def sort_entries(cart):
4251
"""Sort a users shopping cart in alphabetically order.
4352
44-
:param cart: dict - a users shopping cart dictionary.
45-
:return: dict - users shopping cart sorted in alphabetical order.
46-
"""
53+
Parameters:
54+
cart (dict): A users shopping cart dictionary.
55+
56+
Returns:
57+
dict: A sers shopping cart sorted in alphabetical order.
58+
"""
4759

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

5062

5163
def send_to_store(cart, aisle_mapping):
5264
"""Combine users order to aisle and refrigeration information.
5365
54-
:param cart: dict - users shopping cart dictionary.
55-
:param aisle_mapping: dict - aisle and refrigeration information dictionary.
56-
:return: dict - fulfillment dictionary ready to send to store.
66+
Parameters:
67+
cart (dict): The users shopping cart dictionary.
68+
aisle_mapping (dict): The aisle and refrigeration information dictionary.
69+
70+
Returns:
71+
dict: The fulfillment dictionary ready to send to store.
5772
"""
73+
5874
fulfillment_cart = {}
5975

6076
for key in cart.keys():
@@ -66,9 +82,12 @@ def send_to_store(cart, aisle_mapping):
6682
def update_store_inventory(fulfillment_cart, store_inventory):
6783
"""Update store inventory levels with user order.
6884
69-
:param fulfillment cart: dict - fulfillment cart to send to store.
70-
:param store_inventory: dict - store available inventory
71-
:return: dict - store_inventory updated.
85+
Parameters:
86+
fulfillment cart (dict): The fulfillment cart to send to store.
87+
store_inventory (dict): The stores available inventory.
88+
89+
Returns:
90+
dict: The store_inventory updated.
7291
"""
7392

7493
for key, values in fulfillment_cart.items():

exercises/concept/mecha-munch-management/dict_methods.py

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
def add_item(current_cart, items_to_add):
55
"""Add items to shopping cart.
66
7-
:param current_cart: dict - the current shopping cart.
8-
:param items_to_add: iterable - items to add to the cart.
9-
:return: dict - the updated user cart dictionary.
7+
Parameters:
8+
current_cart (dict): The current shopping cart.
9+
items_to_add (iterable): The items to add to the cart.
10+
11+
Returns:
12+
dict: The updated user cart dictionary.
1013
"""
1114

1215
pass
@@ -15,8 +18,11 @@ def add_item(current_cart, items_to_add):
1518
def read_notes(notes):
1619
"""Create user cart from an iterable notes entry.
1720
18-
:param notes: iterable of items to add to cart.
19-
:return: dict - a user shopping cart dictionary.
21+
Parameters:
22+
notes (iterable): Group of items to add to cart.
23+
24+
Returns:
25+
dict: A user shopping cart dictionary.
2026
"""
2127

2228
pass
@@ -25,9 +31,12 @@ def read_notes(notes):
2531
def update_recipes(ideas, recipe_updates):
2632
"""Update the recipe ideas dictionary.
2733
28-
:param ideas: dict - The "recipe ideas" dict.
29-
:param recipe_updates: iterable - with updates for the ideas section.
30-
:return: dict - updated "recipe ideas" dict.
34+
Parameters:
35+
ideas (dict): The "recipe ideas" dict.
36+
recipe_updates (iterable): Updates for the ideas section.
37+
38+
Returns:
39+
dict: The updated "recipe ideas" dict.
3140
"""
3241

3342
pass
@@ -36,8 +45,11 @@ def update_recipes(ideas, recipe_updates):
3645
def sort_entries(cart):
3746
"""Sort a users shopping cart in alphabetically order.
3847
39-
:param cart: dict - a users shopping cart dictionary.
40-
:return: dict - users shopping cart sorted in alphabetical order.
48+
Parameters:
49+
cart (dict): A users shopping cart dictionary.
50+
51+
Returns:
52+
dict: A sers shopping cart sorted in alphabetical order.
4153
"""
4254

4355
pass
@@ -46,9 +58,12 @@ def sort_entries(cart):
4658
def send_to_store(cart, aisle_mapping):
4759
"""Combine users order to aisle and refrigeration information.
4860
49-
:param cart: dict - users shopping cart dictionary.
50-
:param aisle_mapping: dict - aisle and refrigeration information dictionary.
51-
:return: dict - fulfillment dictionary ready to send to store.
61+
Parameters:
62+
cart (dict): The users shopping cart dictionary.
63+
aisle_mapping (dict): The aisle and refrigeration information dictionary.
64+
65+
Returns:
66+
dict: The fulfillment dictionary ready to send to store.
5267
"""
5368

5469
pass
@@ -57,9 +72,12 @@ def send_to_store(cart, aisle_mapping):
5772
def update_store_inventory(fulfillment_cart, store_inventory):
5873
"""Update store inventory levels with user order.
5974
60-
:param fulfillment cart: dict - fulfillment cart to send to store.
61-
:param store_inventory: dict - store available inventory
62-
:return: dict - store_inventory updated.
75+
Parameters:
76+
fulfillment cart (dict): The fulfillment cart to send to store.
77+
store_inventory (dict): The stores available inventory.
78+
79+
Returns:
80+
dict: The store_inventory updated.
6381
"""
6482

6583
pass

0 commit comments

Comments
 (0)