Python Arguments MCQs

This section focuses on the "Arguments" in Python. These Multiple Choice Questions (mcq) should be practiced to improve the Python skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. In Python, how are arguments passed?

A. pass by value
B. pass by reference
C. It gives options to user to choose
D. Both A and B

View Answer


2. Which of the following is incorrect way of using an argument while defining a function in Python, where var1 and var2 are two arguments?

A. def fn(var1, var2)
B. def fn(var1, var2=5)
C. def fn(*var1, var2)
D. def fn(var1,*var2)

View Answer


3. Which of the following is not a type of argument in Python?

A. Keyword
B. Variable argument count
C. Positional
D. None of these

View Answer


4. Which of the following is the property of variable argument count?

A. More than one argument can be used while calling the function.
B. It should be always last while declaring the arguments.
C. Both A and B
D. None of these

View Answer


5. Which of the following would result in an error?

A. def function1(var1=2, var2):
    var3=var1+var2
     return var3
    function1(3)

B. def function1(var1, var2):
    var3=var1+var2
    return var3
    function1(var1=2,var2=3)

C. def function1(var1, var2):
    var3=var1+var2
    return var3
    function1(var2=2,var1=3)

D. def function1(var1, var2=5):
    var3=var1+var2
    return var3
    function1(2,3)

View Answer


6. What will be the output of the following Python code?

def function1(var1=5, var2=7):
    var2=9
    var1=3
    print (var1, " ", var2)
function1(10,12)

A. 5 7
B. 3 9
C. 10 12
D. Error

View Answer


7. What will be the output of the following Python code?

def function1(var1,var2=5):
    var1=2
    var3=var1*var2
    return var3
var1=3
print(function1(var1,var2))

A. 10
B. 15
C. Error as var2 is not defined while calling the function
D. Does not give any error as var2 is a default argument

View Answer


8. . Which among the following are mutable objects in Python?
(i) List
(ii) Integer
(iii) String
(iv) Tuple

A. i only
B. i and ii only
C. iii and iv only
D. iv only

View Answer


9. What will be the output of the following Python code?

def function1(var1):
    var1=var1+10
    print (var1)
var1=12
function1(var1)
print(var1)

A. 22
     22
B. 12
     12
C. 22
     22
D. 12
     22

View Answer


10. What will be the output of the following Python code?

def fn(var1):
    var1.pop(1)
var1=[1,2,3]
fn(var1)
print(var1)

A. [1,2,3]
B. [1,3]
C. [2,3]
D. [1,2]

View Answer






Discussion


* You must be logged in to add comment.