Python-Quizzes | Python Tuples Quiz | Question 10

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

filter_none

edit
close

play_arrow

link
brightness_4
code

import sys 
L1 = tuple() 
print(sys.getsizeof(L1), end = " "
L1 = (1, 2
print(sys.getsizeof(L1), end = " "
L1 = (1, 3, (4, 5)) 
print(sys.getsizeof(L1), end = " "
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3)) 
print(sys.getsizeof(L1)) 

chevron_right


(A) 0 2 3 10
(B) 32 34 35 42
(C) 48 64 72 128
(D) 48 144 192 480


Answer: (C)

Explanation: An Empty Tuple has 48 Bytes as Overhead size and each additional element requires 8 Bytes.
(1, 2) Size: 48 + 2 * 8 = 64
(1, 3, (4, 5)) Size: 48 + 3 * 8 = 72
(1, 2, 3, 4, 5, [3, 4], ‘p’, ‘8’, 9.777, (1, 3)) Size: 48 + 10 * 8 = 128

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.