A. None B. Int C. Double D. Public: E. Null Answer. A
A. None B. Int C. Double D. Public: E. Null Answer. A
What is the default return value for a function that does not return any
value explicitly?
A. None
B. int
C. double
D. public
E. null
Click here to view the answer.
Answer. A
Q-2. Which of the following items are present in the function header?
A. function name
B. function name and parameter list
C. parameter list
D. return value
Click here to view the answer.
Answer. B
A. brackets
B. parentheses
C. curly braces
D. quotation marks
Click here to view the answer.
Answer. B
Q-4. Which of the following keywords marks the beginning of the function
block?
A. fun
B. define
C. def
D. function
Click here to view the answer.
Answer. C
Q-5. What is the name given to that area of memory, where the system stores
the parameters and local variables of a function call?
A. a heap
B. storage area
C. a stack
D. an array
Click here to view the answer.
Answer. C
Q-6. Which of the following function definition does not return any value?
def f(number):
print(f(5))
A. return “number”
B. print(number)
C. print(“number”)
D. return number
print(message * num)
func('Welcome')
func('Viewers', 3)
A. Welcome
Viewers
B. Welcome
ViewersViewersViewers
C. Welcome
Viewers,Viewers,Viewers
D. Welcome
Answer. B
print(text)
num = num - 1
myfunc('Hello', 4)
A. HelloHelloHelloHelloHello
B. HelloHelloHelloHello
C. invalid call
D. infinite loop
Q-10. Which of the following would you relate to a function call made with an
argument passed as its parameter?
A. function invocation
B. pass by value
C. pass by reference
D. pass by name
Click here to view the answer.
Answer. B
x = x + y
y += 1
print(x, y)
func(y = 2, x = 1)
A. 1 3
B. 2 3
C. The program has a runtime error because x and y are not defined.
D. 3 2
E. 3 3
Click here to view the answer.
Answer. E
Q-12. What is the output of the following code snippet?
num = 1
def func():
num = 3
print(num)
func()
print(num)
A. 1 3
B. 3 1
C. The program has a runtime error because x is not defined.
D. 1 1
E. 3 3
Click here to view the answer.
Answer. B
Q-13. What is the output of the following code snippet?
num = 1
def func():
num = num + 3
print(num)
func()
print(num)
A. 1 4
B. 4 1
C. The program has a runtime error because the local variable ‘num’ referenced before
assignment.
D. 1 1
E. 4 4
Click here to view the answer.
Answer. C
num = 1
def func():
global num
num = num + 3
print(num)
func()
print(num)
A. 1 4
B. 4 1
C. The program has a runtime error because the local variable ‘num’ referenced before
assignment.
D. 1 1
E. 4 4
Click here to view the answer.
Answer. E
x = x + y
y += 1
print(x, y)
test()
A. 1 3
B. 3 1
C. The program has a runtime error because x and y are not defined.
D. 1 1
E. 3 3
Click here to view the answer.
Answer. E
Q-16. What is the output of the following code snippet?
x = x + y
y += 1
print(x, y)
test(2, 1)
A. 1 3
B. 2 3
C. The program has a runtime error because x and y are not defined.
D. 3 2
E. 3 3
Click here to view the answer.
Answer. D
x = x + y
y += 1
print(x, y)
test(y = 2, x = 1)
A. 1 3
B. 2 3
C. The program has a runtime error because x and y are not defined.
D. 3 2
E. 3 3
Click here to view the answer.
Answer. E
exp = lambda x: x ** 3
print(exp(2))
A. 6
B. 222
C. 8
D. None of the above
Click here to view the answer.
Answer. C
myList = [lambda x: x ** 2,
lambda x: x ** 3,
lambda x: x ** 4]
for f in myList:
print(f(3))
A. 27
81
343
B. 6
9
12
C. 9
27
81
D. 8
27
64
Click here to view the answer.
Answer. C