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.
Contents
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.
Examples
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 “[]”.
Example:
List is Mutable
- Yes list is mutable.
- Content of the list can be changed after it has been created.
List operations
List supports following operations:
- Concatenation
- Repetition
- Membership
- Slicing
Concatenation
- Concatenation refers to joining two List.
- Plus (‘+’) is used as concatenation operator.
- Concatenating List with other data type produces TypeErrors.
Example:
Repetition
- Repetition as it name implies used to replicate a list at specified no of times.
- Asterisk (‘*’) is used as repetition operator.
Membership
- 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.
Example:
Slicing
- 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.
Examples:
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.
Examples:
List methods | List Functions
Nested List
One list appears as an element inside another list.
Example:
this website was really helpfull.
Keep Learning!!
GREAT WEB SITE for tutors and students.
A lot of effort has been put in for presentation in an effective manner.
Must be recommend to all cbse class 11 and 12 students by their school.