Python practice: Tuples, Sets & Deduplication

Chapter 12 · 8 questions · included in full access

  1. Question 1 · easy

    Create immutable tax rate tuple

    Create a tuple gst_tiers = (0.05, 0.12, 0.18, 0.28). Print the standard 18% tier gst_tiers[2]:

    Solve it in your browser
  2. Question 2 · easy

    Unpack order tuple

    Given record = ("SO-901", "Delhi", 14500), unpack into order_id, city, amount = record. Print f"{order_id} billed ₹{amount}":

    Solve it in your browser
  3. Question 3 · easy

    Deduplicate lead list with set

    Given leads = ["Ravi", "Asha", "Ravi", "Priya", "Asha"], convert to unique_leads = set(leads). Print len(unique_leads):

    Solve it in your browser
  4. Question 4 · easy

    Customer retention with set intersection

    Given jan = {"C1", "C2", "C3"} and feb = {"C2", "C3", "C4"}, find retained customers using jan & feb. Print sorted(list(retained)):

    Solve it in your browser
  5. Question 5 · easy

    Customer churn with set difference

    Given jan = {"C1", "C2", "C3"} and feb = {"C2", "C3", "C4"}, find churned accounts using jan - feb. Print sorted(list(churned)):

    Solve it in your browser
  6. Question 6 · easy

    Consolidated catalog with set union

    Given store_a = {"Desk", "Lamp"} and store_b = {"Lamp", "Chair"}, find combined catalog using store_a | store_b. Print sorted(list(all_prods)):

    Solve it in your browser
  7. Question 7 · easy

    Fast membership check in sets

    Given verified = {"user_1", "user_2", "user_3"}, check if "user_2" is in verified and print the boolean result:

    Solve it in your browser
  8. Question 8 · medium

    New customer acquisitions

    Given old_cust = {"A", "B"} and new_cust = {"B", "C", "D"}, find newly acquired accounts using new_cust - old_cust. Print sorted(list(acquired)):

    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