The one-page answer to the most repeated question in first-year Python papers — with the "Know Your Brackets" trick, a decision guide, and runnable Indian examples from the CodeKitab textbook.
Short answer: a list is an ordered collection you can change ([ ]); a tuple is an ordered collection you cannot change (( )); a set is an unordered collection of unique items ({ }); a dictionary stores key → value pairs ({key: value}). The brackets alone tell you the type — that is the memory trick students in the book use, and it is all you need for a 2-mark question. The 5-mark and 10-mark versions want the comparison table, one example of each, and when to use which. All of that is below.
In this article
- Why Python has four collections
- Comparison table (the exam answer)
- List — ordered and changeable
- Tuple — ordered and fixed
- Set — unique items only
- Dictionary — key → value records
- Which one should you use? (decision guide)
- Mistakes that cost marks
- Practice questions
- FAQ
Why Python has four collections
Suppose you must store the names of 60 students in a class. Sixty variables — student1, student2 … student60 — would be impossible to loop over or manage. A collection is one variable that holds many values:
students = ["Amit", "Neha", "Ravi"]
print(students[0]) # Amit
print(len(students)) # 3
Python gives four collection types because real data comes in four shapes: things that change (a shopping cart), things that must not change (a date of birth), things that must be unique (phone numbers in a contact list), and things you look up by a label (name → marks). Each type is optimised for one shape.
Comparison table — the exam answer
![Know your brackets: [ ] list, ( ) tuple, { } set, {k: v} dictionary in Python](https://cdn.shopify.com/s/files/1/0721/5326/8333/files/blog-list-tuple-set-dict-brackets.jpg)
| List | Tuple | Set | Dictionary | |
|---|---|---|---|---|
| Brackets | [1, 2, 3] |
(1, 2, 3) |
{1, 2, 3} |
{"a": 1} |
| Ordered | Yes | Yes | No | Yes (insertion order, Python 3.7+) |
| Mutable (changeable) | Yes | No | Yes | Yes |
| Duplicates | Allowed | Allowed | Not allowed | Keys must be unique; values may repeat |
| Indexing | lst[0] |
tup[0] |
Not possible | By key: d["name"]
|
| Empty literal | [] |
() |
set() |
{} |
| Can be a dict key? | No | Yes | No | No |
| Typical use | Marks, cart items, players | Coordinates, RGB, fixed records | Unique IDs, tags, de-duplication | Student record, product → price |
| Speed of "is x in it?" | Slow (scans every item) | Slow | Very fast (hashing) | Very fast (hashing) |
If the examiner asks "differentiate between list and tuple" (the most common form), give four points: brackets, mutability, speed/memory (tuples are slightly faster and smaller), and usability as a dictionary key. Add one example of each.
List — ordered and changeable
A list keeps items in the order you added them, allows duplicates, and lets you add, remove and reorder. It is the default collection for most programs.
subjects = ["Maths", "Science", "English"]
subjects.append("Hindi") # add at the end
subjects.insert(1, "Computer") # add at position 1
subjects.remove("Science") # remove by value
print(subjects)
print("First subject:", subjects[0])
subjects.sort() # sort A-Z, in place
print("Sorted:", subjects)
['Maths', 'Computer', 'English', 'Hindi']
First subject: Maths
Sorted: ['Computer', 'English', 'Hindi', 'Maths']
Methods to remember: append(), insert(), remove(), pop() (remove by index and return it), sort(), reverse(), index(), count(), plus the built-ins len(), max(), min(), sum(). Slicing works exactly like strings: marks[1:3].
A food-delivery app keeps your cart as a list: you append items, remove items, and it stays in the order you added them.
Tuple — ordered and fixed
A tuple is a list that is locked. Once created, its items cannot be changed, which makes it safe for data that must never be edited by accident — a screen coordinate, an RGB colour, a date of birth.
point = (10, 20) # packing two values into a tuple
x, y = point # unpacking into two variables
print("x =", x, ", y =", y)
rgb = (255, 0, 0) # red
print("Red value:", rgb[0])
x = 10 , y = 20
Red value: 255
Three facts examiners test:
-
point[0] = 99raisesTypeError: 'tuple' object does not support item assignment. - A one-item tuple needs a trailing comma:
(5,). Plain(5)is just the number 5. - Because tuples are immutable they are hashable, so they can be dictionary keys and set members — a list cannot. Example:
fares = {("Delhi", "Agra"): 150, ("Delhi", "Jaipur"): 280}.
Functions that return more than one value actually return a tuple — return total, average — which is why you can write t, a = calculate(marks).
Set — unique items only
You collected 500 mobile numbers for a college fest and some are repeated. A set keeps only the unique ones, automatically, and answers "is this number already there?" almost instantly.
cities = {"Delhi", "Mumbai", "Delhi", "Chennai"}
print(cities) # the duplicate Delhi is removed
cities.add("Pune")
a = {1, 2, 3}
b = {3, 4, 5}
print("Union:", a | b) # everything from both
print("Intersection:", a & b) # common to both
print("Difference:", a - b) # only in a
{'Delhi', 'Mumbai', 'Chennai'}
Union: {1, 2, 3, 4, 5}
Intersection: {3}
Difference: {1, 2}

Sets have no order, so your output may list the cities differently, and cities[0] is an error. The quickest way to remove duplicates from any list is unique = list(set(my_list)). One trap: {} creates an empty dictionary; for an empty set write set().
Dictionary — key → value records
A real student record is not a bare value, it is labelled data: name, roll, marks. A dictionary stores such data as key : value pairs so you look things up by a meaningful name instead of a position — like finding a word's meaning in a real dictionary.
student = {"name": "Priya", "roll": 12, "marks": 88}
print(student["name"]) # look up by key
student["marks"] = 92 # update a value
student["city"] = "Pune" # add a new pair
del student["roll"] # delete a pair
for key, value in student.items():
print(key, ":", value)
Priya
name : Priya
marks : 92
city : Pune
Reading a missing key with student["phone"] raises KeyError. Use student.get("phone", "Not given") to return a default instead of crashing. Other methods: keys(), values(), items(), update(), pop(). Your phone contacts (name → number), a product catalogue (name → price) and a UPI app (name → account) are all dictionaries.
Which one should you use? Decision guide

| Your need | Best collection | Why |
|---|---|---|
| Ordered data you will change (cart, marks, squad) | List | Ordered and mutable |
| Ordered data that must stay fixed (coordinates, DOB, RGB) | Tuple | Ordered and immutable; can be a dict key |
| Only unique values; fast membership test | Set | Duplicates removed automatically; hashing |
| Label each value (name → marks, product → price) | Dictionary | Look up by a meaningful key |
| Plain text | String | A sequence of characters (immutable, like a tuple of letters) |
Quick rule from the book: key–value → Dictionary, unique → Set, fixed → Tuple, changeable → List, text → String.
They are often combined. The Student Marks Management System project stores five marks in a list and then puts that list inside a dictionary under the key "marks":
student = {"name": "Priya"}
marks = [92, 85, 78, 90, 80]
student["marks"] = marks
total = sum(student["marks"])
print("Name:", student["name"])
print("Total:", total, "/ 500")
print("Percentage:", total / 5, "%")
Name: Priya
Total: 425 / 500
Percentage: 85.0 %
Mistakes that cost marks
- Writing "a tuple is not ordered." Tuples are ordered; sets are not. Immutable ≠ unordered.
- Saying dictionaries are unordered. Since Python 3.7 they keep insertion order. Older textbooks are wrong on this.
-
Indexing a set (
s[0]) in a code-tracing question. It raisesTypeError. - Forgetting the comma in a one-element tuple.
-
Using
{}for an empty set. That is a dictionary; useset(). -
Modifying a list while looping over it. Items get skipped. Loop over a copy:
for x in marks[:]:. -
Using a list as a dictionary key —
TypeError: unhashable type: 'list'. Convert it to a tuple.
Practice questions (try before the exam)
- Store the marks of five subjects in a list and print the highest, lowest and average.
- Write a program that reads 10 mobile numbers and prints how many are unique.
- Create a tuple of your college's (latitude, longitude) and unpack it into two variables.
- Build a dictionary of three products with prices; add GST at 18 % to each price and print the updated dictionary.
- Given
a = [1, 2, 2, 3, 3, 3], produce[1, 2, 3]in one line. - Predict the output:
t = (1, 2); t = t + (3,); print(t)— and explain why this does not violate immutability.
Worked solutions to these, and 20 more exercises on collections, are in Chapter 5 of the book, along with the IPL Team Manager and Phone Contact Book projects that use all four types together.
This article is adapted from Chapter 5 of Python Programming for Indian Students — 180 full-colour pages, every program tested on Python 3.14, Indian examples throughout, practice questions with answers after every chapter. Written for B.Tech, BCA and CBSE Class 11–12 students.
Also read: Python Programming Notes for B.Tech 1st Year (unit-wise).
FAQ
What is the main difference between a list and a tuple in Python?
A list is mutable — you can add, remove and change its items — and is written with square brackets. A tuple is immutable and written with parentheses. Tuples are slightly faster, use less memory, and can be used as dictionary keys.
Which is faster, list or tuple?
Tuples are marginally faster to create and iterate because Python does not need to allow for changes. For first-year programs the difference is invisible; choose by meaning (fixed vs changeable), not speed.
Can a list contain a dictionary, or a dictionary contain a list?
Yes, both. A list of dictionaries ([{"name": "Amit"}, {"name": "Neha"}]) is the standard way to store many records; a dictionary with a list value ({"marks": [90, 85]}) is how the marks project in the book works.
Is a Python dictionary ordered?
Yes, since Python 3.7 a dictionary remembers the order in which keys were inserted. If your textbook says dictionaries are unordered, it is describing Python 3.6 and earlier.
When should I use a set instead of a list?
When you need only unique values, or when you repeatedly check whether something is present. Checking membership in a set is effectively instant; in a list Python must scan every item.
How do I convert between list, tuple and set?
Use the constructor functions: list(x), tuple(x), set(x). For example tuple([1, 2, 3]) gives (1, 2, 3) and list(set([1, 1, 2])) gives [1, 2].
Written by the CodeKitab editorial team at Study Delight Publications. Every program on this page was run on Python 3.14. Last reviewed October 2026.