Give the output of the following Python code.

ICSE Class 10 Robotics & AI PYQ · 2025 Paper · Section A

1(xx)1 Mark · 2025 · Section A · 2025 Paper

Give the output of the following Python code.

my_list = [1, 2, 3, 4]
my_list.append(5)
my_list.insert(2, 10)
print(my_list)
Show SolutionHide Solution↓

[1, 2, 10, 3, 4, 5]

Reason — First, append(5) adds 5 at the end of the list, so the list becomes [1, 2, 3, 4, 5]. Then, insert(2, 10) inserts 10 at index position 2, shifting the existing elements to the right. Hence, the final list printed is [1, 2, 10, 3, 4, 5].

← Previous questionNext question →

Browse the free Robotics & AI sample bank