Advertisements
Advertisements
प्रश्न
What will be the output of the following code snippet?
t = tuple('tuple')
t2 = t[2],
t += t2
print(t)
पर्याय
(‘tuple’)(‘tuple’,‘p’)(‘t’, ‘u’, ‘p’, ‘1’, ‘e’, ‘p’)(‘t’, ‘u’, ‘p’, ‘1’, ‘e’)
MCQ
Advertisements
उत्तर
(‘t’, ‘u’, ‘p’, ‘1’, ‘e’, ‘p’)
Explanation:
- The function
tuple('tuple')breaks the string into individual characters, creatingt = ('t', 'u', 'p', 'l', 'e'). - The statement
t2 = t[2],creates a new tuple containing the character at index 2 (which is'p') because of the trailing comma. - Using
t += t2performs tuple concatenation, joining the two tuples together to produce the final output.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
