GATE DA 2026 · Question 16 · Programming, Data Structures and Algorithms · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Consider the given Python program.
def append_to_lst(val, lst=[]): lst.append(val) return lst print(append_to_lst(1)) print(append_to_lst(2)) print(append_to_lst(3, []))
Which of the following is the correct output of this program?

  1. (A) [1] [2] [3]
  2. (B) [1] [1, 2] [3]
  3. (C) [1] [2] [1, 2, 3]
  4. (D) [1] [1, 2] [1, 3]
Answer

Answer (B)

Answer from the official GATE DA 2026 answer key.

The step-by-step solution, where available, is part of GATE DA Pro. See what Pro includes