GATE DA 2026 — Question 16

Programming, Data Structures and AlgorithmsProgramming in PythonMCQ1 mark · −1/3 if wrongMedium

Consider the given Python program.
python
1def append_to_lst(val, lst=[]):
2    lst.append(val)
3    return lst
4print(append_to_lst(1))
5print(append_to_lst(2))
6print(append_to_lst(3, []))
7
Which of the following is the correct output of this program?
  1. A
    code
    1[1]
    2[2]
    3[3]
    4
  2. B
    code
    1[1]
    2[1, 2]
    3[3]
    4
  3. C
    code
    1[1]
    2[2]
    3[1, 2, 3]
    4
  4. D
    code
    1[1]
    2[1, 2]
    3[1, 3]
    4
Practise the full 2026 paper
Challenge a friend: WhatsApp Telegram
From RENYXERAFree All-India Mock — every SundayA full GATE CS paper, exactly 180 minutes, ranked across India with your GATE score.
Practise more on Programming in PythonTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group