Q.#To create a list
list1 = [5, 3.4, "New Delhi", "20C", 45]
#print the elements of the list list1
list1
[5, 3.4, 'New Delhi', '20C', 45]
list1 = [5, 3.4, "New Delhi", "20C", 45]
#print the elements of the list list1
list1
[5, 3.4, 'New Delhi', '20C', 45]
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →This question tests your understanding of Python's list data type — a mutable, ordered collection that can hold elements of mixed data types (integers, floats, strings, etc.).
The Idea: Why a List?
A list is the right tool here because the problem explicitly asks you to "create a list" and then display it. Python's list is the most fundamental ordered collection — it preserves insertion order, allows duplicates, and can store heterogeneous data (numbers, strings, etc.) in a single variable.
The given code shows exactly this: list1 is assigned a collection of four items of different types — an integer (5), a float (3.4), and two strings ("New Delhi", "20C", 45).
Step-by-Step Trace
The code creates list1 with these elements:
| Position | Value | Data Type |
|---|---|---|
| 0 | 5 | int |
| 1 | 3.4 | float |
| 2 | "New Delhi" | str |
| 3 | "20C" | str |
| 4 | 45 | int |
So list1 has five elements, not four. The last element 45 is an integer, not a string — notice it's written without quotes in the list literal.
When you type list1 in the Python interpreter (or print(list1)), Python displays the list using its standard representation: square brackets, each element shown with its Python literal form. Strings appear in single quotes by default.
A common mistake is miscounting the elements. The list [5, 3.4, "New Delhi", "20C", 45] has five items, not four. The comma after "20C" separates it from 45 — both are distinct elements.
The Output
When you evaluate list1 in the interactive shell, Python prints:
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.