Question:

What will be the output of the following code snippet?

t = tuple('tuple')
t2 = t[2],
t += t2
print(t)

Show Hint

The comma in t2 = t[2], makes a one-item tuple, and += joins it to the end of t.
Updated On: Oct 20, 2026
  • ('tuple')
  • ('tuple','p')
  • ('t', 'u', 'p', 'l', 'e', 'p')
  • ('t', 'u', 'p', 'l', 'e')
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Build the first tuple:
tuple('tuple') turns each character of the string into one item.
So t = ('t', 'u', 'p', 'l', 'e').

Step 2: Understand t2 = t[2],:
t[2] is the item at index 2, which is 'p'.
The comma at the end makes t2 a tuple with one item, so t2 = ('p',). Without the comma it would be just the string 'p'.

Step 3: Understand t += t2:
Tuples cannot be changed. So += builds a new tuple by joining t and t2, and then names it t.
The new t is ('t', 'u', 'p', 'l', 'e', 'p').

Step 4: Check the options:
(A) ('tuple') is only the string 'tuple' in brackets, not a tuple.
(B) ('tuple','p') has two long items, but t holds single characters.
(C) ('t', 'u', 'p', 'l', 'e', 'p') matches the result.
(D) ('t', 'u', 'p', 'l', 'e') ignores the item added by +=.

Final Answer:
The output is ('t', 'u', 'p', 'l', 'e', 'p'), option (C).
Was this answer helpful?
0
0