Wrap-Up Check¶
Please answer the following questions.
# Here is a short answer question.
# This is the nested dictionary example you will work with.
employee_dict = {
'John': {'age': 28, 'position': 'Designer',
'skills': {'soft_skill': 'Creativity',
'technical_skill': 'Figma'}},
'Alice': {'age': 34, 'position': 'Developer',
'skills': {'soft_skill': 'Communication',
'technical_skill': 'Python'}}
}
# Fill in the missing two lines below to print each employee’s name
# along with their skills using a nested loop.
__________________
__________________
print(f"{name}'s {skill_type_key}: {skill_expertise_value}")
Q-1: - Recommended Time: Spend at most 2 minutes - Put “I am not sure” and click “Save” if unsure of the answer.
For the code piece above, fill in the missing two lines to print each employee’s name along with their skills using a nested loop.
Note: Be sure to indent the second line correctly.
Recommended Time: Spend at most 5 minutes - Put “# I am not sure” and click “Save&Run” if unsure of the answer.
- Write the function
happy_hour_specials(menu_items)
: menu_items
is a list of tuples. Each tuple contains(name, category, is_today_special, price)
.Return a nested dictionary that only includes the items marked as today’s special (
is_today_special
isTrue
) and where the prices are less than or equal to15
. Each outer key is thecategory
and each value is a dictionary. The inner dictionary keys arename
, and the values areprice
.
Example Input
Expected Output
happy_hour_specials([("Margherita", "Pizza", True, 15), ("Pepperoni", "Pizza", False, 22), ("Hawaiian", "Pizza", True, 10), ("Caesar", "Salad", True, 10)])
{"Pizza": {"Margherita": 15, "Hawaiian": 10}, "Salad": {"Caesar": 10}}
happy_hour_specials([("Margherita", "Pizza", True, 15), ("Pepperoni", "Pizza", False, 22), ("Olive-Walnut", "Pasta", True, 20), ("Caesar", "Salad", True, 10)])
{"Pizza": {"Margherita": 15}, "Salad": {"Caesar": 10}}
happy_hour_specials([("Lentil", "Soup", True, 15), ("Salmorejo", "Soup", False, 18), ("Harvest", "Salad", False, 18), ("Fruit", "Salad", True, 8)])
{"Soup": {"Lentil": 15}, "Salad": {"Fruit": 8}}
Remember to click ‘Save&Run’ frequently to save your latest answer.
Recommended Time: Spend at most 5 minutes - Put “# I am not sure” and click “Save&Run” if unsure of the answer.
- Finish the function
top_employee(employee_dict)
below: The
employee_dict
is a nested dictionary. The outermost dictionary has unique employee names as keys and a dictionary as values.Each second-level dictionary has keys of age and performance. The value for the key
age
is a number, the value for the keyperformance
is a dictionary.The
performance
dictionary has keys of quarters (Q1
,Q2
,Q3
,Q4
), and a performance score as the value out of 100.The goal is to return a new dictionary where the keys are the names of top employees (those whose average performance score is above or equal to
90
), and the values are their average performance scores.
Example Input
Expected Output
top_employee({"Alice": {"age": 30, "performance": {"Q4": 95}}, "Bob": {"age": 33, "performance": {"Q1": 93, "Q2": 88, "Q3": 95, "Q4": 88}}})
{"Alice": 95, "Bob": 91}
top_employee({"Charlie": {"age": 31, "performance": {"Q3": 70, "Q4": 60}})
{}
top_employee({"Bob": {"age": 33, "performance": {"Q3": 92, "Q4", 92}})
{"Bob": 92}
What to do next¶
Click on the following link to the final page: Thank you!