Test Index

CBSE Class 12 Computer Science 2025 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 1 of 37
Marks: +1, -0
State True or False :
“A Python List must always contain all its elements of same data type.”
Solution:  
Concept:
A Python list is a heterogeneous sequence: each element can be of any data type, and different elements may have different types.
Explanation:
The following list is perfectly valid:
>>> L = [10, 'Ravi', 85.5, True, [1, 2]]
>>> [type(x).__name__ for x in L]
['int', 'str', 'float', 'bool', 'list']
So a list does not need all its elements to be of the same type. The statement is False.
Key point: Python lists (and tuples) can mix data types; a string, by contrast, can hold only characters.
Answer:
Option B (False)
© examsnet.com
Advertisements
Go to Question: