Computer Science

If L1 = [1, 2, 3, 2, 1, 2, 4, 2, …], and L2 = [10, 20, 30, …], then

(Answer using builtin functions only)

  1. (a) Write a statement to count the occurrences of 4 in L1.
    OR
    (b) Write a statement to sort the elements of list L1 in ascending order.

  2. (a) Write a statement to insert all the elements of L2 at the end of L1.
    OR
    (b) Write a statement to reverse the elements of list L2.

Python List Manipulation

2 Likes

Answer

  1. (a) L1.count(4)
    OR
    (b) L1.sort()

  2. (a) L1.extend(L2)
    OR
    (b) L2.reverse()

Answered By

1 Like


Related Questions