Skip to content
Related Articles

Related Articles

Python-Quizzes | Python List Quiz | Question 6

Improve Article
Save Article
Like Article
  • Last Updated : 17 Sep, 2020

Question 6: Find the output of the following program:

def gfg(x,l=[]): 
    for i in range(x): 

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

Answer: (A)

Explanation: l is a name for a variable that points to a list stored in memory. The function call starts off by creating a new list in a new block of memory. l then refers to this new list. It then appends 0, 1, and 4 to this new list. So that’s great.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!