Python practice: Dictionaries & Key-Value Lookups
Chapter 11 · 8 questions · included in full access
Question 1 · easy
Create commission lookup dictionary
Solve it in your browserCreate a dict
rep_rates = {"Asha": 0.12, "Ravi": 0.10, "Priya": 0.15}. Print Asha's rate usingrep_rates["Asha"]:Question 2 · easy
Safe lookup with .get() default
Solve it in your browserGiven
inventory = {"Laptop": 14, "Monitor": 8}, look up"Keyboard"with.get("Keyboard", 0)and print the result:Question 3 · easy
Add and update dictionary keys
Solve it in your browserGiven
targets = {"North": 50000}, update"North"to55000and add"East"as45000. Printtargets:Question 4 · easy
Delete dictionary key
Solve it in your browserGiven
inventory = {"Desk": 5, "DiscontinuedLamp": 0}, remove"DiscontinuedLamp"usingdeland printinventory:Question 5 · easy
Iterate dictionary items to calculate total
Solve it in your browserGiven
sales = {"Q1": 100, "Q2": 150, "Q3": 200}, loop oversales.items()to sum all revenue and printtotal:Question 6 · easy
Inspect dictionary keys and values
Solve it in your browserGiven
dept = {"Asha": "Sales", "Ravi": "Ops"}, printlist(dept.keys())on line 1 andlist(dept.values())on line 2:Question 7 · medium
Nested employee record access
Solve it in your browserGiven
emp = {"name": "Neha", "details": {"dept": "Analytics", "salary": 65000}}, print Neha's salary usingemp["details"]["salary"]:Question 8 · medium
Build category price directory
Solve it in your browserCreate an empty dict
catalog = {}. Add"Laptop": 45000and"Mouse": 800. Multiply Laptop quantity2by price and print cost:
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing