PRACTICE • LEARN • GROW
Module 5: Functions - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 5: Functions - Final Quiz Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What does a Python function return if it executes to completion without encountering an explicit
return statement?
A.
0
B.
False
C.
None
D.
Raises an UnreturnedError
Explanation & Key
Correct Answer:
2
What is the output of the following function with a mutable default argument when called twice?
def add_item(item, basket=[]):
basket.append(item)
return basket
add_item("apple")
print(add_item("banana"))
A.
['banana']
B.
['apple', 'banana']
C.
['apple']
D.
TypeError
Explanation & Key
Correct Answer:
3
What is the recommended pythonic pattern to avoid the mutable default argument trap?
A.
def func(basket=list()):
B.
def func(basket=None): if basket is None: basket = []
C.
def func(basket=copy([])):
D.
def func(basket=()): basket = list(basket)
Explanation & Key
Correct Answer:
4
What data type does
*args collect extra positional arguments into inside a function?
A.
list
B.
tuple
C.
dict
D.
set
Explanation & Key
Correct Answer:
5
What data type does
**kwargs collect extra keyword arguments into inside a function?
A.
tuple
B.
list
C.
dict
D.
set
Explanation & Key
Correct Answer:
6
What will be printed by this argument unpacking call?
def calc(a, b, c):
return a + b * c
nums = [2, 3, 4]
print(calc(*nums))
A.
20
B.
14
C.
24
D.
TypeError
Explanation & Key
Correct Answer:
7
What is the output of sorting this list of tuples using a lambda key?
students = [("Asha", 22), ("Vikram", 19), ("Neha", 25)]
students.sort(key=lambda s: s[1])
print(students[0][0])
A.
Asha
B.
Vikram
C.
Neha
D.
19
Explanation & Key
Correct Answer:
8
What does LEGB stand for in Python's variable scope resolution order?
A.
Loop, Entry, Global, Binary
B.
Local, Enclosing, Global, Built-in
C.
Linear, External, Guaranteed, Bound
D.
Logical, Environment, Gateway, Base
Explanation & Key
Correct Answer:
9
Which keyword allows modifying a variable defined in the outer enclosing function of a nested function?
A.
global
B.
nonlocal
C.
outer
D.
parent
Explanation & Key
Correct Answer:
10
What is the default recursion limit enforced by CPython to prevent C stack overflows?
A.
100 calls
B.
1000 calls
C.
65536 calls
D.
Unlimited
Explanation & Key
Correct Answer:
11
What will be the output of this recursive function call?
def mystery(n):
if n <= 1:
return 1
return n + mystery(n - 2)
print(mystery(5))
A.
15
B.
9
C.
5
D.
12
Explanation & Key
Correct Answer:
12
Which of the following is true about Python lambda functions?
A.
They can contain multiple statements separated by semicolons
B.
They are syntactically restricted to a single expression whose value is returned automatically
C.
They can include loops and try-except blocks
D.
They must always be assigned to a variable
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong