0% found this document useful (0 votes)
2 views1 page

Python List Notes Class11

Python lists are ordered, mutable collections that can store various data types, defined using square brackets. Key methods include append, extend, insert, remove, pop, clear, index, count, sort, reverse, and copy, each serving specific functions for list manipulation. Lists allow for dynamic changes, making them a versatile data structure in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Python List Notes Class11

Python lists are ordered, mutable collections that can store various data types, defined using square brackets. Key methods include append, extend, insert, remove, pop, clear, index, count, sort, reverse, and copy, each serving specific functions for list manipulation. Lists allow for dynamic changes, making them a versatile data structure in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Lists - Class 11 CBSE Notes

Definition:
A list in Python is an ordered, mutable collection of elements. Lists can store integers, strings,
floats, or even other lists. They are written with square brackets []. Key Properties: Ordered: Items
have a defined order. Mutable: You can change, add, or remove items. Heterogeneous: Can
contain different data types. Creating a List:
l = [1, 2, 3, "apple", 4.5]

Accessing Elements:
l[0] → 1
l[-1] → 4.5

Function / Method Description Example

append(x) Adds an element at the end my_list.append(10)


extend(iterable) Adds multiple elements my_list.extend([4,5])
insert(i, x) Inserts at index i my_list.insert(1, 'apple')
remove(x) Removes first occurrence my_list.remove(3)
pop([i]) Removes & returns element my_list.pop(2)
clear() Removes all elements my_list.clear()
index(x) Returns index of value my_list.index(7)
count(x) Counts occurrences my_list.count(2)
sort() Sorts list ascending my_list.sort()
reverse() Reverses list my_list.reverse()
copy() Returns a shallow copy new_list = my_list.copy()

You might also like