Open In App
Related Articles

Python-Quizzes | Python List Quiz | Question 6

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Find the output of the following program: 

Python3

def gfg(x,l=[]):
    for i in range(x):
        l.append(i*i)
    print(l)
 
gfg(3,[3,2,1])

                    
(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
Please comment below if you find anything wrong in the above post

Last Updated : 17 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads