Python-Quizzes | Python Tuples Quiz | Question 6
source link: https://www.geeksforgeeks.org/python-quizzes-python-tuples-quiz-question-6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
- Last Updated : 18 Sep, 2020
Question 6: What is the output of the following program?
T
=
'geeks'
a, b, c, d, e
=
T
b
=
c
=
'*'
T
=
(a, b, c, d, e)
print
(T)
(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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK