Carefully analyze the following Python program segment and determine the…

2026

Carefully analyze the following Python program segment and determine the correct output:

L = [4, 7, 2, 8, 2, 5]

L.insert(1, 0)

L.pop(2)

L.remove(2)

L.extend([3, 1])

print(L)

  1. A.

    [0, 4, 8, 2, 5, 3, 1]

  2. B.

    [4, 0, 8, 2, 5, [3, 1]]

  3. C.

    [4, 0, 8, 2, 5, [3, 1]]

  4. D.

    [4, 0, 8, 2, 5, 3, 1]

Attempted by 85 students.

Show answer & explanation

Correct answer: D

Initial list is [4, 7, 2, 8, 2, 5]. L.insert(1, 0) adds 0 at index 1: [4, 0, 7, 2, 8, 2, 5]. L.pop(2) removes element at index 2 (7): [4, 0, 2, 8, 2, 5]. L.remove(2) removes the first occurrence of value 2: [4, 0, 8, 2, 5]. L.extend([3, 1]) appends 3 and 1: [4, 0, 8, 2, 5, 3, 1]. The final output is [4, 0, 8, 2, 5, 3, 1].

Explore the full course: Rssb Senior Computer Instructor