Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python-Quizzes | Python List Quiz | Question 4

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Find the output of the following program: 

Python3




def addToList(listcontainer):
    listcontainer += [10]
mylistContainer = [10, 20, 30, 40]
addToList(mylistContainer)
print (len(mylistContainer))

(A)

4

(B)

5

(C)

6

(D)

10


Answer: (B)

Explanation:

In Python, everything is a reference, and references are passed by value. Parameter passing in Python is the same as reference passing in Java. As a consequence, the function can modify the value referred by passed argument, i.e. the value of the variable in the caller’s scope can be changed. Here the task of the function “addToList” is to add an element 10 in the list, So this will increase the length of the list by 1. So the output of the program is 5.


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 17 Sep, 2020
Like Article
Save Article
Similar Reads