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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
