Lists · Class 11 · CBSE · Science Computer Science

What is the value of nums after executing nums = [2, 4, 6]; nums.insert(1, 3)?

Practice question from Lists (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-EB49C1

What is the value of nums after executing nums = [2, 4, 6]; nums.insert(1, 3)?

  1. A.[2, 4, 3, 6]
  2. B.[2, 3, 4, 6]Correct answer
  3. C.[3, 2, 4, 6]
  4. D.[2, 4, 6, 3]

Solution

The insert() method places an element at the specified index. Therefore, 3 is inserted before the element originally at index 1, producing [2, 3, 4, 6].

More from Lists

All of Lists

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed