Python-Quizzes | Python Tuples Quiz | Question 8

Question 8: What is the output of the following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

T = 'geeks'
a, b, c, d, e =
b = c = '*'
T = (a, b, c, d, e) 
print(T) 

chevron_right


(A) (‘g’, ‘*’, ‘*’, ‘k’, ‘s’)
(B) (‘g’, ‘e’, ‘e’, ‘k’, ‘s’)
(C) (‘geeks’, ‘*’, ‘*’)
(D) KeyError


Answer: (A)

Explanation: A tuple is created as T = (‘g’, ‘e’, ‘e’, ‘k’, ‘s’), then it is unpacked into a, b, c, d and e, mapping from ‘g’ to a and ‘s’ to e. b and c which are both ‘e’ are equal to ‘*’ and then the existing tuple is replaced by packing a, b, c, d, and e into a tuple T.

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.