List Class 11 Python Notes covers List Methods, List Slicing, Traversing List, List Concatenation, Repetition and Membership operations with examples. This List Manipulation in Python Class 11 is prepared for all students of Computer Science Class 11 to understand each concept easily and get highest marks. This List in Python Class 11 Notes is written very concisely as per CBSE suggested Syllabus.
What is List in Python?
- List is built in sequence data type in python.
- Stores multiple values
- List item can be of different data types
- All the items are comma separated and enclosed in square bracket.
- Individual item in a list can be accessed using index which begins from 0.
Accessing elements in a List
- Individual item in a list can be accessed using indexes.
- Indexes are unique numbers assigned to each item in a list to identify them
- Index always begins from 0 and written in square brackets “”.
List is Mutable
- Yes list is mutable.
- Content of the list can be changed after it has been created.
List supports following operations:
- Concatenation refers to joining two List.
- Plus (‘+’) is used as concatenation operator.
- Concatenating List with other data type produces TypeErrors.
- Repetition as it name implies used to replicate a list at specified no of times.
- Asterisk (‘*’) is used as repetition operator.
- Membership operation refers to checking an item is exists in the list or not.
- Python uses ‘in’ and ‘not in’ as membership operator.
- ‘in’ returns true if the item specified present in the list.
- ‘not in’ returns true if the item specified present in the list.
- Extracting a subset of items from given list is called slicing
- Subset occurred after slicing contains contiguous items.
- Slicing is done using index range like List[start_index : end_index : step_value]
- End index is always excluded in resultant subset of list.
- Negative index can also be used for slicing.
Traversing a List
- Traversing a List refers to accessing each item a given list sequentially.
- for or while loop can be used for traversing a list.
List methods | List Functions
One list appears as an element inside another list.