Python practice: Dictionaries & Key-Value Lookups

Chapter 11 · 8 questions · included in full access

  1. Question 1 · easy

    Create commission lookup dictionary

    Create a dict rep_rates = {"Asha": 0.12, "Ravi": 0.10, "Priya": 0.15}. Print Asha's rate using rep_rates["Asha"]:

    Solve it in your browser
  2. Question 2 · easy

    Safe lookup with .get() default

    Given inventory = {"Laptop": 14, "Monitor": 8}, look up "Keyboard" with .get("Keyboard", 0) and print the result:

    Solve it in your browser
  3. Question 3 · easy

    Add and update dictionary keys

    Given targets = {"North": 50000}, update "North" to 55000 and add "East" as 45000. Print targets:

    Solve it in your browser
  4. Question 4 · easy

    Delete dictionary key

    Given inventory = {"Desk": 5, "DiscontinuedLamp": 0}, remove "DiscontinuedLamp" using del and print inventory:

    Solve it in your browser
  5. Question 5 · easy

    Iterate dictionary items to calculate total

    Given sales = {"Q1": 100, "Q2": 150, "Q3": 200}, loop over sales.items() to sum all revenue and print total:

    Solve it in your browser
  6. Question 6 · easy

    Inspect dictionary keys and values

    Given dept = {"Asha": "Sales", "Ravi": "Ops"}, print list(dept.keys()) on line 1 and list(dept.values()) on line 2:

    Solve it in your browser
  7. Question 7 · medium

    Nested employee record access

    Given emp = {"name": "Neha", "details": {"dept": "Analytics", "salary": 65000}}, print Neha's salary using emp["details"]["salary"]:

    Solve it in your browser
  8. Question 8 · medium

    Build category price directory

    Create an empty dict catalog = {}. Add "Laptop": 45000 and "Mouse": 800. Multiply Laptop quantity 2 by price and print cost:

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing