You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/_hidden/mc_nested-nt.rst
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,28 +5,30 @@ Practice
5
5
:autograde: unittest
6
6
:nocodelens:
7
7
8
-
Finish the function ``table_reservation(reservation_dict, guest_num)`` below:
9
-
- It takes a nested dictionary ``reservation_dict`` representing a restaurant's current reservation situation for a day and a specific number of guests ``guest_num`` as input.
10
-
- ``reservation_dict`` is a nested dictionary with outer keys as time slots in a day (e.g., breakfast, lunch, dinner), and values as a list of dictionaries where the inner keys are unique researvation IDs and the values are the number of guests for that reservation.
11
-
- Your goal is to count and return the number of reservations in ``reservation_dict`` with the same guest number as the input ``guest_num``.
8
+
Finish the function ``add_quantity(item_dict, quantities)`` that “zips” quantities onto their corresponding items inside each category, returning a nested dictionary:
9
+
- It takes a dictionary ``item_dict`` and a list ``quantities`` as input, the lengths of ``item_dict`` and ``quantities`` are the same.
10
+
- For dict ``item_dict``, keys are category names (strings), values are lists of unique item names (strings), each list contains at least one item (no empty lists).
11
+
- For list ``quantities``, it contains the quantity for each item in ``item_dict``. Quantities are given in the same order as the items appear in item_dict when iterated in insertion order, category by category, left to right.
12
+
- The total number of quantities equals the total number of items in all categories combined.
13
+
- The function should return a new nested dictionary where the outer dictionary keys are the category names, the inner dictionary keys are the item names, and the inner dictionary values are the quantities.
Copy file name to clipboardExpand all lines: _sources/_hidden/mc_puzzle_bank.rst
+16-13Lines changed: 16 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,29 @@
3
3
:adaptive:
4
4
:practice: T
5
5
6
-
Finish the function ``table_reservation(reservation_dict, guest_num)`` below:
7
-
- It takes a nested dictionary ``reservation_dict`` representing a restaurant's current reservation situation for a day and a specific number of guests ``guest_num`` as input.
8
-
- ``reservation_dict`` is a nested dictionary with outer keys as time slots in a day (e.g., breakfast, lunch, dinner), and values as a list of dictionaries where the inner keys are unique researvation IDs and the values are the number of guests for that reservation.
9
-
- Your goal is to count and return the number of reservations in ``reservation_dict`` with the same guest number as the input ``guest_num``.
6
+
Finish the function ``add_quantity(item_dict, quantities)`` that “zips” quantities onto their corresponding items inside each category, returning a nested dictionary:
7
+
- It takes a dictionary ``item_dict`` and a list ``quantities`` as input, the lengths of ``item_dict`` and ``quantities`` are the same.
8
+
- For dict ``item_dict``, keys are category names (strings), values are lists of unique item names (strings), each list contains at least one item (no empty lists).
9
+
- For list ``quantities``, it contains the quantity for each item in ``item_dict``. Quantities are given in the same order as the items appear in item_dict when iterated in insertion order, category by category, left to right.
10
+
- The total number of quantities equals the total number of items in all categories combined.
11
+
- The function should return a new nested dictionary where the outer dictionary keys are the category names, the inner dictionary keys are the item names, and the inner dictionary values are the quantities.
Copy file name to clipboardExpand all lines: _sources/_hidden/mc_start.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ Python 3 with Nested Dictionaries
2
2
=====================================
3
3
Welcome to the Python 3 with Nested Dictionaries study!
4
4
This study is part of a research project at the University of Michigan, and your participation will contribute to our understanding of how students learn programming concepts.
5
-
We are researchers at University of Michigan who are trying to improve the teaching and learning of programming.
5
+
We are researchers at the University of Michigan who are trying to improve the teaching and learning of programming.
0 commit comments