List Manipulation in Python Class 11 Notes
Welcome to the complete List Manipulation in Python — Class 11 Notes. Lists are the most widely used data structure in the CBSE Computer Science / Informatics Practices syllabus, and almost every board paper carries 3–4 marks directly from this chapter. These notes cover the complete CBSE syllabus — indexing, all list operations, traversal, every built-in function/method, nested lists, and the suggested programs — with syntax, examples and outputs.
sort() vs sorted() are the two most repeated trick questions on Lists. Run every example yourself — typing the code is the fastest way to remember it.Quick Overview — What You Will Learn
| # | Topic | Key Concepts | Exam Weight |
|---|---|---|---|
| 1 | Introduction to Lists | Definition, creation, mutability | ⭐⭐ |
| 2 | List Indexing | Positive index, negative index, IndexError | ⭐⭐⭐ |
| 3 | List Operations | Concatenation, Repetition, Membership, Slicing | ⭐⭐⭐ |
| 4 | Traversing a List | for loop, while loop | ⭐⭐ |
| 5 | Built-in Functions/Methods | len(), append(), sort(), sorted(), etc. | ⭐⭐⭐ |
| 6 | Nested Lists | List of lists, double indexing | ⭐⭐ |
| 7 | Suggested Programs | Max/Min/Mean, Linear Search, Frequency Count | ⭐⭐⭐ |
Section 1 · Introduction · ⭐⭐
📦 What is a List in Python?
A list is an ordered, mutable collection of items enclosed in square brackets
[ ], separated by commas. A list can store different data types together.
subjects = [“Physics”, “Chemistry”, “Maths”, “CS”]
mixed = [10, “Amit”, 45.5, True] # different data types together
empty_list = [] # an empty list
List Mutability
Lists are mutable — unlike strings, individual elements CAN be changed after creation.
mylist[2] = “Rust” # allowed — lists are mutable
print(mylist)
s = “Hello”
# s[0] = “h” # TypeError — strings are immutable
append(), sort() etc. change the original list directly.Section 2 · Indexing · ⭐⭐⭐
🔢 List Indexing
Every element has a fixed position called its index. Python supports positive indexing (0 onward, left to right) and negative indexing (-1 onward, right to left).
| Element | C | C++ | Java | Python | PHP |
|---|---|---|---|---|---|
| Positive Index | 0 | 1 | 2 | 3 | 4 |
| Negative Index | -5 | -4 | -3 | -2 | -1 |
print(mylist[0]) # C
print(mylist[4]) # PHP (last element)
print(mylist[-1]) # PHP (last element)
print(mylist[-2]) # Python
print(mylist[10]) # IndexError: list index out of range
Formula: negative_index = positive_index − len(list)
Section 3 · List Operations · ⭐⭐⭐
⚙️ List Operations
CBSE defines four core operations — concatenation, repetition, membership, slicing.
1. Concatenation ( + )
list2 = [“a”, “b”]
print(list1 + list2)
2. Repetition ( * )
print(list1 * 3)
print([0] * 5) # common way to initialise a list
[0, 0, 0, 0, 0]
3. Membership ( in, not in )
print(“C” in mylist) # True
print(“Ruby” not in mylist) # True
in / not in are case-sensitive for strings.4. Slicing
Syntax:
list[start : stop : step]— the stop index is never included.
print(mylist[2:5]) # stop excluded
print(mylist[:3]) # start omitted -> 0
print(mylist[2:]) # stop omitted -> end
print(mylist[::2]) # every 2nd element
print(mylist[::-1]) # reversed list
[‘C’, ‘C++’, ‘Java’]
[‘Java’, ‘Python’, ‘PHP’]
[‘C’, ‘Java’, ‘PHP’]
[‘PHP’, ‘Python’, ‘Java’, ‘C++’, ‘C’]
list[::-1] reverses any list — appears in almost every board paper.Section 4 · Traversal · ⭐⭐
🔄 Traversing a List Using Loops
mylist = [“C”, “C++”, “Java”, “Python”, “PHP”]
for item in mylist:
print(item)
for i in range(len(mylist)):
print(i, “-“, mylist[i])
i = 0
while i < len(mylist):
print(mylist[i])
i += 1
for i in range(len(list)) when you need both index and value.Section 5 · Built-in Functions/Methods · ⭐⭐⭐
🛠️ Built-in Functions and Methods on Lists
len() and list()
print(len(mylist)) # 5
print(list(“Python”)) # string to list
print(list((1, 2, 3))) # tuple to list
[‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
[1, 2, 3]
append() and extend()
append(x)adds a single item.extend(seq)adds each element separately.
mylist.append(“Python”)
mylist.append([“PHP”, “Go”]) # adds ONE item — nested list!
print(mylist)
mylist2 = [“C”, “C++”, “Java”]
mylist2.extend([“Python”, “PHP”])
print(mylist2)
[‘C’, ‘C++’, ‘Java’, ‘Python’, ‘PHP’]
append() always adds exactly ONE item. extend() unpacks and adds each element individually.insert()
mylist.insert(2, “Rust”)
print(mylist)
count() and index()
print(nums.count(10)) # 3
print(nums.index(30)) # 3 — first index found
3
remove() and pop()
remove(x)deletes by value.pop(i)deletes by index and returns it.
mylist.remove(“C++”)
print(mylist)
removed = mylist.pop(1)
print(removed)
print(mylist)
Java
[‘C’, ‘Python’, ‘PHP’]
reverse(), sort() and sorted()
nums.sort() # changes nums itself
print(nums)
nums2 = [45, 12, 89]
print(sorted(nums2)) # NEW list returned
print(nums2) # original unchanged!
[12, 45, 89]
[45, 12, 89]
sort() changes the original list and returns None. sorted(list) returns a NEW list, original untouched.min(), max() and sum()
print(min(nums))
print(max(nums))
print(sum(nums))
print(sum(nums) / len(nums)) # mean
89
225
45.0
📋 Complete Summary Table
| Method | What it Does | Changes Original? |
|---|---|---|
len(list) | Returns number of elements | No |
list(seq) | Converts a sequence into a list | No |
append(x) | Adds one item at the end | Yes |
extend(seq) | Adds each element of seq | Yes |
insert(i, x) | Inserts x at index i | Yes |
count(x) | Counts occurrences of x | No |
index(x) | Index of first occurrence of x | No |
remove(x) | Removes first occurrence of x | Yes |
pop(i) | Removes & returns item at index i | Yes |
reverse() | Reverses list in place | Yes |
sort() | Sorts in place; returns None | Yes |
sorted(list) | Returns a NEW sorted list | No |
min(list) | Smallest element | No |
max(list) | Largest element | No |
sum(list) | Sum of numeric elements | No |
Section 6 · Nested Lists · ⭐⭐
🧩 Nested Lists
A nested list is a list inside another list — useful for tables, matrices, or grouped records.
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(student[2]) # [78, 85, 92]
print(student[2][1]) # 85
print(matrix[1][2]) # 6
for row in matrix:
for value in row:
print(value, end=” “)
print()
4 5 6
7 8 9
matrix[row][col].Section 7 · Suggested Programs · ⭐⭐⭐
💻 Common Programs for CBSE Practicals & Board Exams
Program 1 — Maximum, Minimum and Mean of a List
maximum = max(numbers)
minimum = min(numbers)
mean = sum(numbers) / len(numbers)
print(“Maximum:”, maximum)
print(“Minimum:”, minimum)
print(“Mean:”, mean)
Without using built-in functions (common exam variant):
maximum = numbers[0]
minimum = numbers[0]
total = 0
for n in numbers:
if n > maximum:
maximum = n
if n < minimum:
minimum = n
total += n
mean = total / len(numbers)
print(“Maximum:”, maximum, ” Minimum:”, minimum, ” Mean:”, mean)
Program 2 — Linear Search on a List of Numbers
search_value = int(input(“Enter number to search: “))
found = False
for i in range(len(numbers)):
if numbers[i] == search_value:
print(“Found at index:”, i)
found = True
break
if not found:
print(“Value not found in the list”)
Program 3 — Counting Frequency of Elements in a List
freq = {}
for n in numbers:
if n in freq:
freq[n] += 1
else:
freq[n] = 1
for key, value in freq.items():
print(key, “occurs”, value, “time(s)”)
20 occurs 2 time(s)
30 occurs 1 time(s)
40 occurs 1 time(s)
numbers.count(10) gives its frequency in one line.Frequently Asked Questions
Is a list mutable or immutable in Python?
A list is mutable — its elements can be changed after creation, unlike a string.
Difference between append() and extend()?append(x) adds exactly one item (even a whole list, as a nested element). extend(seq) adds each element individually.
Difference between remove() and pop()?remove(x) deletes by value. pop(i) deletes by index and returns the removed value.
Difference between sort() and sorted()?sort() sorts in place and returns None. sorted(list) returns a new sorted list, original unchanged.
What does list[::-1] do?
It reverses the list using a step of -1.
How to access an element inside a nested list?
Use double indexing: list[outer_index][inner_index].
Quick Practice Links
📝 List MCQs Class 11 | Python Compiler | 📂 Practical File | 📖 All Class 11 Notes
Explore More Class 11 CS Notes
📄 Python String | 📌 Python Tuple | 📖 Python Dictionary | 🔧 Python Functions
Found an error or a missing example? Drop a comment below — we fix issues quickly!
