Matric number: 20/85/0040
Course code: COM 315
Course title: Python programming language
There are several library functions in python list and explain at least five functions with a short simple
code
1. `len()`: Returns the length of a list.
Example: `my_list = [1, 2, 3, 4, 5]`
`print(len(my_list))`
Output: `5`
2. `append()`: Adds an element to the end of a list.
Example: `my_list = [1, 2, 3]`
`my_list.append(4)`
`print(my_list)`
Output: `[1, 2, 3, 4]`
3. `remove()`: Removes the first occurrence of a specified element from a list.
Example: `my_list = [1, 2, 3, 4, 5]`
`my_list.remove(3)`
`print(my_list)`
Output: `[1, 2, 4, 5]`
4. `sort()`: Sorts the elements in a list in ascending order.
Example: `my_list = [5, 3, 1, 4, 2]`
`my_list.sort()`
`print(my_list)`
Output: `[1, 2, 3, 4, 5]`
5. `index()`: Returns the index of the first occurrence of a specified element in a list.
Example: `my_list = [1, 2, 3, 4, 5]`
`print(my_list.index(3))`
Output: `2`