Computer Science, asked by tulikajain7272, 10 months ago

Start with the list(8,9,10). Do the following using list functions:
(a) set the second entry(index 1) to 17
(b) add 4,5 and 6 to the end of the list
(c) remove the first entry from the list (d) sort the list
(e) double the list (f) insert 25 at index 3

Answers

Answered by patra14825752ote8cm
0

Here is Your Answer

1. del[a : b] :- This method deletes all the elements in range starting from index ‘a’ till ‘b’ mentioned in arguments.

1. del[a : b] :- This method deletes all the elements in range starting from index ‘a’ till ‘b’ mentioned in arguments.2. pop() :- This method deletes the element at the position mentioned in its arguments.

# Python code to demonstrate the working of

# del and pop()

# initializing list

lis = [2, 1, 3, 5, 4, 3, 8]

# using del to delete elements from pos. 2 to 5

# deletes 3,5,4

del lis[2 : 5]

# displaying list after deleting

print ("List elements after deleting are : ",end="")

for i in range(0, len(lis)):

print(lis[i], end=" ")

3. insert(a, x) :- This function inserts an element at the position mentioned in its arguments. It takes 2 arguments, position and element to be added at respective position.

Hope it Helpful Answer and Please make it Brainliest

Similar questions