Computer Science, asked by cyanide0911, 1 year ago



Start with the list [8,9,10]. Do the followings:

(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
18

Brainly.in

What is your question?

Secondary School Computer science 49 points

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

Ask for details Follow Report by Megha20052002agrawal 14.02.2019

Answers

Hey mate....

here's the answer...

# 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=" ")

print("\r")

# using pop() to delete element at pos 2

# deletes 3

lis.pop(2)

# displaying list after popping

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

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

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

Please make it Brainliest

Answered by KhanLayba0107
1

Answer:

Let list l=[8,9,10]

(a) l[1]=17

(b) l.extend([4,5,6])

(c) l.pop(0) (OR) l.remove(8)

(d) l.sort()

(e) 2*l (OR) l.extend(l)

(f) l.insert(3,25)

Explanation:

(a) To change and set another value of an index we have

  name of list[index number]=The value to be given

(b) To add multiple elements at the end of a list we use extend method.

  name of list.extend([elements to be added seperated by commas])

(c) To remove an element from a list we use  

    (i) pop method.

    name of list.pop(index number of element to be removed)

    (ii) remove method

    name of list.remove(value of element to be removed)

(d) To sort a list we use sort method.

  name of list.sort()

(e) To double a list we can

    (i) Multiply

    2*name of list

    (ii)extend method

    name of list.extend(name of list)

(f) To insert an element at a given position we use insert method.

 name of list.insert(index number of desired position,desired value)

Similar questions