Question 37 of 97
Q.What will be the output of the following code snippet ? t = tuple('tuple') t2 = t[2], t += t2 print(t) (A) ('tuple') (B) ('tuple','p') (C) ('t', 'u', 'p', 'l', 'e', 'p') (D) ('t', 'u', 'p', 'l', 'e')
Sikkim CbseCBSE Class XII Board 2026MCQ· 1mImportance★★★★★
38% · 37/97 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →tuple('tuple') splits the string into five single-character elements; t2 = t[2], (note the trailing comma) packs ('p',); t += t2 concatenates, giving ('t', 'u', 'p', 'l', 'e', 'p') — option (C).
Concept — two tuple facts this question tests
tuple()on a string iterates character by character.tuple('tuple')is('t','u','p','l','e'), never('tuple',). To get a one-element tuple holding the whole word you would write('tuple',)explicitly.- A trailing comma packs a tuple.
t2 = t[2],is tuple packing: it is the same ast2 = (t[2],). Andt += t2on a tuple builds a new tuple equal tot + t2(tuples are immutable, so+=rebindstto the concatenation).
Step-by-step trace
t = tuple('tuple')
t2 = t[2],
t += t2
print(t)
| Step | Statement | What happens | t | t2 |
|---|---|---|---|---|
| 1 | t = tuple('tuple') | the string is iterated char by char | ('t','u','p','l','e') | — |
| 2 | t2 = t[2], | t[2] is 'p'; the comma packs it into a tuple | ('t','u','p','l','e') | ('p',) |
| 3 | t += t2 | concatenation: t + ('p',) rebinds t | ('t','u','p','l','e','p') | ('p',) |
| 4 | print(t) | prints the six-element tuple | — | — |
Expected output:
('t', 'u', 'p', 'l', 'e', 'p')
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.