Python practice: Tuples, Sets & Deduplication
Chapter 12 · 8 questions · included in full access
Question 1 · easy
Create immutable tax rate tuple
Solve it in your browserCreate a tuple
gst_tiers = (0.05, 0.12, 0.18, 0.28). Print the standard 18% tiergst_tiers[2]:Question 2 · easy
Unpack order tuple
Solve it in your browserGiven
record = ("SO-901", "Delhi", 14500), unpack intoorder_id, city, amount = record. Printf"{order_id} billed ₹{amount}":Question 3 · easy
Deduplicate lead list with set
Solve it in your browserGiven
leads = ["Ravi", "Asha", "Ravi", "Priya", "Asha"], convert tounique_leads = set(leads). Printlen(unique_leads):Question 4 · easy
Customer retention with set intersection
Solve it in your browserGiven
jan = {"C1", "C2", "C3"}andfeb = {"C2", "C3", "C4"}, find retained customers usingjan & feb. Printsorted(list(retained)):Question 5 · easy
Customer churn with set difference
Solve it in your browserGiven
jan = {"C1", "C2", "C3"}andfeb = {"C2", "C3", "C4"}, find churned accounts usingjan - feb. Printsorted(list(churned)):Question 6 · easy
Consolidated catalog with set union
Solve it in your browserGiven
store_a = {"Desk", "Lamp"}andstore_b = {"Lamp", "Chair"}, find combined catalog usingstore_a | store_b. Printsorted(list(all_prods)):Question 7 · easy
Fast membership check in sets
Solve it in your browserGiven
verified = {"user_1", "user_2", "user_3"}, check if"user_2"is inverifiedand print the boolean result:Question 8 · medium
New customer acquisitions
Solve it in your browserGiven
old_cust = {"A", "B"}andnew_cust = {"B", "C", "D"}, find newly acquired accounts usingnew_cust - old_cust. Printsorted(list(acquired)):
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing