Python Tuples Class 11: One-Item Tuples, Tuple Assignment, Nested Tuples and Programs
Updated 17 October 2026 · Fact-checked
A tuple is an ordered, immutable sequence written with commas, usually inside round brackets; a one-item tuple needs a trailing comma, as in (5,). Items can be read by index and slice but not changed, and the only tuple methods are count() and index(). Tuple assignment such as a, b = b, a swaps values without a temporary variable.
You can read items and slice a tuple to get a new tuple, but assigning to an item such as t[0] = 1 gives a TypeError.
Illustration drawn for QuestionBuddy.
Understand Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11)
Creating a tuple. The comma makes the tuple, not the brackets. t = 1, 2, 3 is a tuple; (5) is just the integer 5; (5,) is a one-item tuple; () is the empty tuple; tuple("abc") gives ('a', 'b', 'c').
Reading. Indexing and slicing work as for lists and strings, and a slice gives a new tuple: for t = (4, 9, 2, 9, 7), t[1:4] is (9, 2, 9) and t[::-1] is (7, 9, 2, 9, 4).
Immutable. t[0] = 1 raises TypeError, and a tuple has no append or remove. A tuple may CONTAIN a list, and that list can still be changed in place: with t = (1, [2, 3]), t[1].append(4) is allowed. A tuple can be rebuilt, for example t = t + (5,), which makes a new tuple and re-points t.
Operations and functions. + joins tuples (both sides must be tuples), * repeats, in tests membership. len(t), min(t), max(t), sum(t) work as for lists. t.count(x) counts occurrences and t.index(x) gives the first position (ValueError if absent). sorted(t) returns a LIST, so use tuple(sorted(t)) to get a sorted tuple.
Tuple assignment. The right side is fully evaluated before any name on the left is changed: a, b = b, a swaps two values, and a, b = b, a + b uses the OLD a and b on the right. The number of names on the left must equal the number of items on the right.
Returning many values. A function can return several values as one tuple: return lo, hi gives (lo, hi), which the caller unpacks with x, y = f().
Lists or tuples. Use a tuple for data that must not change (a date of birth, coordinates). Tuples are also usable as dictionary keys, but a list is not.
Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11): key facts
- Making tuples
- (5,) one item
- (5) is an integer
- t = 1, 2, 3 is a tuple
- () is empty
- tuple(seq) converts
- The comma makes the tuple.
- Tuple methods
- count(x) occurrences
- index(x) first position
- no append, remove or sort
- Only two methods exist.
- Functions
- len
- min
- max
- sum
- sorted(t) returns a list
- tuple(sorted(t)) returns a tuple
- sum needs numbers.
- Tuple assignment
- a, b = b, a swaps
- right side is evaluated first
- names on the left equal items on the right
- a, b = b, a + b uses the old values.
How to answer Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11) questions
To trace tuple code, decide first whether each name holds a tuple, a list or a single value.
- 1Check for the trailing comma before calling an expression a tuple.
- 2Write each tuple with its indices before slicing.
- 3For tuple assignment evaluate the whole right side using the old values, then assign left to right.
- 4Remember that tuples cannot be modified, so look for TypeError in assignments such as t[i] = x.
- 5Print sorted(t) as a list in square brackets and tuple(...) in round brackets.
Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11) in real life
The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
Coordinates of a school gate
Suppose a map program stores the position of a gate as pos = (12, 40) and a student writes pos[0] = 15 to "move it".
What happens and how can the position be changed?
Try it first, then show the solutionSolution
- A tuple is immutable, so pos[0] = 15 raises TypeError.
- Build a new tuple: pos = (15, pos[1]), giving (15, 40).
Answer: TypeError; use pos = (15, pos[1]).
Memory hook: Tuples are sealed: replace the whole tuple, not a part.
Tricks to remember Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11)
Short memory aids. Say each one aloud once, then use it on a question the same day.
Comma makes the tuple
Brackets are optional, the comma is not: (5,) is a tuple but (5) is not.
Use it when: Type questions.
Right first, then left
In a, b = b, a + b the whole right side is worked out before assigning.
Use it when: Swap and Fibonacci-style questions.
Two methods only
count and index are all a tuple has.
Use it when: Theory MCQs.
Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11): solved examples
Ordered from board level to HOTS. Try each one before you open the solution.
Example 1: Type of (5) · 1 mark · MCQBoard level
What is the type of (5)?
(a) tuple
(b) int
(c) list
(d) str
Try it first, then show the solutionSolution
- Brackets alone do not make a tuple; there is no comma.
- (5) is the integer 5 in brackets.
Answer: (b) int
Example 2: Tuple functions · 3 marks · Short answerBoard level
For t = (6, 3, 8, 3, 5, 3) give t[2:5], t.count(3), t.index(3), len(t), min(t), max(t) and sorted(t). (3 marks)
Try it first, then show the solutionSolution
- Indices 2, 3, 4 give (8, 3, 5).
- 3 occurs three times; its first index is 1; len is 6.
- min is 3 and max is 8.
- sorted(t) returns a list: [3, 3, 3, 5, 6, 8].
Answer: (8, 3, 5), 3, 1, 6, 3, 8, [3, 3, 3, 5, 6, 8]
Example 3: Tuple assignment · 4 marks · Short answerHarder board level
Give the output:
a, b = 3, 4
a, b = b, a
print(a, b)
a, b = b, a + b
print(a, b)(4 marks)
Try it first, then show the solutionSolution
- Start a = 3, b = 4.
- a, b = b, a evaluates the right side as (4, 3), so a = 4 and b = 3. First print: 4 3.
- a, b = b, a + b has right side (3, 4 + 3) = (3, 7), using the old a and b. So a = 3, b = 7. Second print: 3 7.
Answer: 4 3
3 7
Example 4: Mutable item inside a tuple · 5 marks · Short answerHOTS / competency
Trace the code and give the output. State which line fails and why. (5 marks)
t = (1, [2, 3], "a")
t[1].append(4)
print(t)
t = t + (5,)
print(t, len(t))
t[2] = "b"Try it first, then show the solutionSolution
- t[1] is a list inside the tuple. append(4) changes that list, which the tuple allows: (1, [2, 3, 4], 'a').
- t + (5,) builds a new tuple and re-points t: (1, [2, 3, 4], 'a', 5), length 4.
- t[2] = "b" fails with TypeError because a tuple does not support item assignment.
Answer: (1, [2, 3, 4], 'a')
(1, [2, 3, 4], 'a', 5) 4
TypeError at t[2] = "b"
Example 5: Statistics on a tuple · 5 marks · Short answerHarder board level
For marks = (78, 91, 66, 91, 85) write code to print the mean, the highest mark, how many times it occurs and its first position, and give the output. (5 marks)
Try it first, then show the solutionSolution
- total = sum(marks) = 78 + 91 + 66 + 91 + 85 = 411; mean = 411 / 5 = 82.2.
- top = max(marks) = 91.
- marks.count(top) = 2 and marks.index(top) = 1.
- Code: print(sum(marks) / len(marks), top, marks.count(top), marks.index(top)).
Answer: 82.2 91 2 1
Where students lose marks in Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11)
The slips examiners see most often, and what to write instead.
Mistake: Forgetting the comma in a one-item tuple
Believing the brackets create the tuple.
Wrong working
t = (5); len(t) raises TypeError
Right working
t = (5,); len(t) is 1
Do this: Add the trailing comma.
Usually costs: 1 mark
Mistake: Trying to change a tuple item
Treating a tuple like a list.
Wrong working
t[0] = 9
Right working
t = (9,) + t[1:]
Do this: Create a new tuple.
Usually costs: 1 to 2 marks
Mistake: Writing the swap with the new values
Working left to right instead of evaluating the right side first.
Wrong working
a, b = b, a + b with a = 3, b = 4 worked out as a = 4 and then b = a + b = 8
Right working
b = old a + old b = 3 + 4 = 7, so a = 4 and b = 7
Do this: Use old values on the right.
Usually costs: 1 mark
Exam tips
- Write whether the result of sorted() is a list when a tuple is given.
- State that a tuple has only two methods, count and index.
- In swap questions write the old values first.
- Quote the error type TypeError for any attempt to modify a tuple.
Practice questions on Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11)
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
Which of these is a tuple with exactly one item?
(a) (7)
(b) [7]
(c) (7,)
(d) {7}Hint
The comma.
Answer
(c) (7,)
Q2 · 1 mark · Assertion-reasonHarder board level
Assertion (A): For t = (1, 2, 3), the statement t[0] = 9 raises an error.
Reason (R): A tuple is an immutable sequence.
(a) Both A and R are true, and R is the correct explanation of A.
(b) Both A and R are true, but R is not the correct explanation of A.
(c) A is true, but R is false.
(d) A is false, but R is true.Hint
Item assignment.
Answer
(a) Both A and R are true, and R is the correct explanation of A.
Q3 · 4 marks · Short answerHarder board level
Give the output:
t = (3, 1, 2) print(sorted(t), t, tuple(sorted(t)), t * 2, t + (0,))(4 marks)
Hint
sorted gives a list.
Answer
sorted(t) is the list [1, 2, 3]; t is unchanged (3, 1, 2); tuple(sorted(t)) is (1, 2, 3); t * 2 is (3, 1, 2, 3, 1, 2); t + (0,) is (3, 1, 2, 0). Output: [1, 2, 3] (3, 1, 2) (1, 2, 3) (3, 1, 2, 3, 1, 2) (3, 1, 2, 0)
Q4 · 5 marks · Short answerHarder board level
Write a program for the tuple t = (2, 5, 2, 3, 5, 2) that prints each distinct value once, in the order of first appearance, with its frequency. Give the output. (5 marks)
Hint
Keep a list of values already seen.
Answer
seen = []; for x in t: if x not in seen: seen.append(x); print(x, t.count(x)). Output lines: 2 3, then 5 2, then 3 1.
Q5 · 5 marks · Short answerHOTS / competency
Give the output of the program:
t = ((1, 2), (3, 4, 5)) print(len(t), t[1][2], t[0] + t[1], len(t[0] + t[1])) pairs = ((1, 2), (3, 4)) for a, b in pairs: print(a * b)(5 marks)
Hint
Joining two tuples gives one longer tuple.
Answer
len(t) is 2 (two inner tuples); t[1][2] is 5; t[0] + t[1] is (1, 2, 3, 4, 5) with length 5. The loop unpacks each pair: 1 * 2 = 2 and 3 * 4 = 12. Output: 2 5 (1, 2, 3, 4, 5) 5, then 2, then 12.
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.What makes a one-item tuple?Show answer
A trailing comma, as in (5,).
2.Name the two tuple methods.Show answer
count() and index().
3.What does sorted(t) return?Show answer
A list.
4.How do you swap a and b?Show answer
a, b = b, a.
5.Can a tuple hold a list?Show answer
Yes, and that list can be changed in place.
Tuples: Immutability, Operations, Tuple Assignment and Programs (CBSE 11): frequently asked questions
Why use a tuple instead of a list?
For fixed data; it is safer from accidental change and can be used as a dictionary key.
Can I delete one item of a tuple?
No; you can only rebuild a new tuple without it, or delete the whole tuple with del.
Is t = 1, 2, 3 valid?
Yes; the commas make it a tuple.