Worked Examples · Example 4.1
Q.#list1 is the list of six even numbers
list1 = [2,4,6,8,10,12]
print(list1)
[2, 4, 6, 8, 10, 12]
#list2 is the list of vowels
list2 = ['a','e','i','o','u']
print(list2)
['a', 'e', 'i', 'o', 'u']
#list3 is the list of mixed data types
list3 = [100,23.5,'Hello']
print(list3)
[100, 23.5, 'Hello']
#list4 is the list of lists called nested
#list
list4 =[['Physics',101],['Chemistry',202],
['Mathematics',303]]
print(list4)
[['Physics', 101], ['Chemistry', 202],
['Mathematics', 303]]
list1 = [2,4,6,8,10,12]
print(list1)
[2, 4, 6, 8, 10, 12]
list2 = ['a','e','i','o','u']
print(list2)
['a', 'e', 'i', 'o', 'u']
list3 = [100,23.5,'Hello']
print(list3)
[100, 23.5, 'Hello']
list4 =[['Physics',101],['Chemistry',202],
['Mathematics',303]]
print(list4)
[['Physics', 101], ['Chemistry', 202],
['Mathematics', 303]]
Karnataka PUCTextbookSubjective· 2mImportance★★★★★est
3% · 1/30 Questions
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 →A Python list is an ordered, mutable collection written in square brackets [...]. This textbook example demonstrates its flexibility: a list of numbers, a list of strings, a mixed-type list, and a nested list (lists inside a list) — all printed exactly in the order the elements were written.
What the example demonstrates
#list1 is the list of six even numbers
>>> list1 = [2,4,6,8,10,12]
>>> print(list1)
[2, 4, 6, 8, 10, 12]
#list2 is the list of vowels
>>> list2 = ['a','e','i','o','u']
>>> print(list2)
['a', 'e', 'i', 'o', 'u']
#list3 is the list of mixed data types
>>> list3 = [100,23.5,'Hello']
>>> print(list3)
[100, 23.5, 'Hello']
#list4 is a nested list (a list of lists)
>>> list4 = [['Physics',101],['Chemistry',202],['Mathematics',303]]
>>> print(list4)
[['Physics', 101], ['Chemistry', 202], ['Mathematics', 303]]
Line by line — why each case matters:
list1(all integers) — the square brackets[...]are what create a list; commas separate the elements.print(list1)shows the elements in exactly the order they were typed: a list is an ordered sequence, so position matters and is preserved.list2(all strings) — lists are not only for numbers; any data type works. Note how Python echoes the strings back in quotes.list3(mixed types) — the key teaching point: one list may freely mix anint(100), afloat(23.5) and astr('Hello'). Python allows this because a list stores references to objects, and it never forces one common type (unlike arrays in some other languages). …
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.