Day 12 of 30Logic & Data Structures
🎯Tuples & Sets
🎯 Today's objective
Use fixed sequences (tuples) and unique collections (sets).
📖 Key concepts
- Tuples are ordered & immutable: (lat, lon)
- Sets are unordered & unique: {1, 2, 3}
- Sets remove duplicates fast
- Set ops: union |, intersection &
💻 Try this code
point = (26.07, 87.94) # tuple (can't change)
tags = {"py", "ai", "py"}
print(tags) # {'py', 'ai'} - duplicate gone
print({1,2,3} & {2,3,4}) # {2, 3}👥 Learn it your way
🧒 Young Explorers
A tuple is a locked box (can’t change); a set is a bag that ignores duplicates.
Your task
From a list with repeats, make a set to find the unique items.
💼 Professionals
Use tuples for fixed records/coords and as dict keys; sets for fast membership tests.
Your task
Given two lists of skills, print skills common to both and skills unique to each.
🤖 AI connection
Sets power deduplication and vocabulary building (the unique words a model knows). Tuples often carry fixed feature vectors / coordinates.
✅ Quick check
What makes a tuple different from a list?
Tuples are immutable (cannot be changed).
What does a set automatically remove?
Duplicate values.