04-03-24
-----------
1. APPEND OPERATION:
L=[]
print("APPEND")
e1=int(input("enter first element"))
L.append(e1)
print("after adding the first element the list
is",L)
e2=int(input("enter second element"))
L.append(e2)
print("after adding the second element the list
is",L)
e3=int(input("enter third element"))
L.append(e3)
print("after adding the third element the list
is",L)
2. INSERT OPERATION:
print("INSERT")
i1=int(input("enter the position where we want
to insert"))
v1=int(input("enter the value"))
L.insert(i1,v1)
print("element inserted")
i2=int(input("enter the position where we want
to insert"))
v2=int(input("enter the value"))
L.insert(i2,v2)
print("element inserted")
print("after insert operation the list is",L)
3. DELETE OPERATION:
print("DELETE")
d1=int(input("enter the position of element to be
deleted"))
del L[d1]
print("after deleting the element the list is",L)
4. UPDATE OPERATION:
print("UPDATE")
u1=int(input("enter the index of the element to
be updated"))
new_val=int(input('enter the new value'))
L[u1]=new_val
print("after update the list is",L)
5. REPEAT OPERATION:
print("REPEAT")
r=int(input('enter how many times you want to
repeat the list elements'))
print("The repeated list is",L*r)
6. COUNT
7. MIN
8. MAX
print('COUNT')
print("The number of elemets in list is",len(L))
print("MIN:minimum element in list
is",min(L))
print("MAX:maximum element in list
is",max(L))
9. SLICING:
print('SLICING USING BOTH INDEXES')
l1=int(input('enter left index'))
r1=int(input('enter right index'))
print("After Slicing the list is",L[l1:r1])
print('SLICING USING LEFT INDEX ONLY')
l2=int(input('enter left index'))
print("After Slicing using left index the list
is",L[l1:])
print('SLICING USING RIGHT INDEX
ONLY')
r2=int(input('enter right index'))
print("After Slicing the list is",L[:r1])
10. MERGE OPERATION:
print("MERGE")
M=[100,200,300]
print("after merging the list is",L+M)
11. EXTEND OPERATION:
print("EXTEND")
L.extend(M)
print('after extending the original list is',L)
12. SORT OPERATION:
print("ASCENDING ORDER SORTING")
print("after sotring in ascending order the list
is",L.sort())
print("DESCENDING ORDER SORTING")
print("after sorting in descending order the list
is",L.sort(reverse=True))
13. COPY OPERATION:
print("COPY")
A=L
print("after copying the List L in to A. The list A
is",A)
14. PRINTING/ACCESSING ELEMENTS
OPERATION:
print("ACCESSING")
print('first element in list is',L[0])
print('last element in list is',L[-1])