Python EXP1
Python EXP1
Code:
#creating a list
list=[5,10,15,20,25,30]
print("Original List:",list)
print("Slicing the list, Start index = 2, till index = 4(element at index 4 not
included):",list[2:4])
#modifying a list
list[2]=22
list.append(265)
list.insert(0,111)
list.remove(20)
list.pop(5)
list.sort()
list.reverse()
a=len(list)
print("Lenght of list:",a)
# using loop
for a in list:
Output:
Learning outcomes:
1 Efficiently Manage Data: Lists allow you to store and manipulate collections of items,
enabling you to handle various types of data in a structured way.
2 Access and Modify Elements: You can access, update, and modify individual elements
using indexing, making lists flexible for dynamic data manipulation.
3 Add and Remove Items: Lists provide methods to add new items (append(), extend(),
insert()) and remove items (remove(), pop(), del), allowing for versatile data handling
4 Utilize List Methods: Python lists come with built-in methods that simplify common
tasks, such as sorting, counting occurrences, and finding elements, streamlining data
operations and enhancing productivity.
5 Add and Remove Items: Lists provide methods to add new items (append(), extend(),
insert()) and remove items (remove(), pop(), del), allowing for versatile data handling