Computer Science, asked by josujoshua732, 7 months ago

L=[10,20,30,40]

L1=[500,600]

L2=[35,45]

L1.extend(L2)

L.insert(25,2)

print (L1+L2)

print (L)

print (L.index(30))

print (L2*2)​

Answers

Answered by SASHANKSAHIL
8

Answer:

I have pinned the answer image you can check it out dear

Hope you may get it

Mark as brainliest

Thank You...

Attachments:
Answered by Equestriadash
26

Given statements:

L=[10,20,30,40]

L1=[500,600]

L2=[35,45]

L1.extend(L2)

L.insert(25,2)

print(L1 + L2)

print(L)

print(L.index(30))

print(L2*2)​

Output:

[500, 600, 35, 45, 35, 45]

[10, 20, 30, 40, 2]

2

[35, 45, 35, 45]

Explanation:

L=[10,20,30,40]

L1=[500,600]

L2=[35,45]

These are the given lists.

1. L1.extend(L2)

  • The extend() method is used to extend a given list with another one.

Hence, L1's present value will be:

L1 = [500, 600, 35, 45]  #extending the list with elements from L2

Now, the lists we have are:

L=[10,20,30,40]

L1 = [500, 600, 35, 45]

L2=[35,45]

2. L.insert(25, 2)

  • The insert() method is used to insert an element at a specified index position.

Here, the index position given was 25, which is clearly out of range. Hence, the value (2) will be added to the end of the list.

L's present value will be:

L = [10, 20, 30, 40, 2]

The lists we have now are:

L = [10, 20, 30, 40, 2]

L1 = [500, 600, 35, 45]

L2 = [35, 45]

3. print(L1 + L2)

This is similar to concatenation, which is adding two lists together. The output for that would be:

[500, 600, 35, 45, 35, 45]

4. print(L)

[10, 20, 30, 40, 2]

5. print(L.index(30))

  • The index() method enables a programmer to print the index value of a given element from a list.

The index value of 30 from the list L is 2.

Hence the output:

2

6. print(L2*2)​

This is simply just repeating the elements in the list twice.

[35, 45, 35, 45]

Similar questions