Question 1
Question
Given the following function fun1() Please select the correct function calls
def fun1(name, age):
print(name, age)
Question 2
Question
What is the output of the following function call
def fun1(num):
return num + 25
fun1(5)
print(num)
Question 3
Question
What is the output of the following function call
def outerFun(a, b):
def innerFun(c, d):
return c + d
return innerFun(a, b)
return a
result = outerFun(5, 10)
print(result)
Answer
-
5
-
15
-
(15, 5)
-
Syntax Error
Question 4
Question
Choose the correct function declaration of fun1() so that we can execute the following function call successfully
fun1(25, 75, 55)
fun1(10, 20)
Question 5
Question
What is the output of the add() function call
def add(a, b):
return a+5, b+5
result = add(3, 2)
print(result)
Question 6
Question
What is the output of the following displayPerson() function call
def displayPerson(*args):
for i in args:
print(i)
displayPerson(name="Emma", age="25")
Answer
-
TypeError
-
Emma
25
-
name
age
Question 7
Question
What is the output of the following function call
def fun1(name, age=20):
print(name, age)
fun1('Emma', 25)
Question 8
Question
What is the output of the following display() function call
def display(**kwargs):
for i in kwargs:
print(i)
display(emp="Kelly", salary=9000)
Question 9
Question
Select which true for Python function
Answer
-
A function is a code block that only executes when it is called.
-
Python function always returns a value.
-
A function only executes when it is called and we can reuse it in a program
-
Python doesn’t support nested function
Question 10
Question
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)
Question 11
Question
Select which is true for Python function
Answer
-
A Python function can return only a single value
-
A function can take an unlimited number of arguments.
-
A Python function can return multiple values
-
Python function doesn’t return anything unless and until you add a return statement
Question 12
Question
Python function always returns a value