Python - MCQ
Multiple Choice Questions
Python - Multiple Choice Questions (MCQ) - Python functions, Modules and Packages - Set 27
36. What is the output of the following displayPerson() function call
def displayPerson(*args):
for i in args:
print(i)
displayPerson(name="Emma", age="25")
A). TypeError
B). Emma
25
C). name
age
View Answer
Correct: A
37. Select which true for Python function
A). A function is a code block that only executes when it is called.
B). Python function always returns a value.
C). A function only executes when it is called and we can reuse it in a program
D). Python doesn’t support nested function
View Answer
Correct: A, B, C
38. What is the output of the following code
def outerFun(a, b):
def innerFun(c, d):
return c + d
return innerFun(a, b)
res = outerFun(5, 10)
print(res)
A). 15
B). Syntax Error
C). (5, 10)
View Answer
Correct: A
39. What is the output of the add() function call
def add(a, b):
return a+5, b+5
result = add(3, 2)
print(result)
A). 15
B). 8
C). (8, 7)
D). Syntax Error
View Answer
Correct: C
40. Given the following function fun1() Please select the correct function calls
def fun1(name, age):
print(name, age)
A). fun1(name=’Emma’, age=23)
B). fun1(name=’Emma’, 23)
C). fun1(‘Emma’, 23)
D).
View Answer
Correct: A, C