Question:

State True or False: “A Python List must always contain all its elements of same data type.”

Show Hint

Python’s dynamic typing makes lists versatile.
Always validate your list elements if your logic depends on having a specific data type.
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Python lists are one of the most widely used data structures in Python programming.
They are ordered, mutable, and can store a collection of items in a single variable.
Unlike arrays in languages like C or Java, Python lists are not restricted to a single data type.
This means you can have an integer, a float, a string, and even another list as elements of the same list.
For example, the list [1, "Hello", 3.14, [2, 3]] is completely valid in Python.
This dynamic typing feature provides flexibility and makes Python powerful for rapid development.
However, while it is possible to mix data types, sometimes it is good practice to keep elements of the same type for logical consistency or when performing operations that expect uniform data.
Therefore, the statement that a Python list must always contain elements of the same data type is False.
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions