Python Function MCQ Questions
- Rajesh Singh

- Nov 30, 2024
- 8 min read
Updated: 3 days ago
Function Python Chapter MCQ
Q1. Function keyword use
(a). define
(b). fun
(c). def
(d). function
Answer-(c)
Q2. Function header items present
(a). function name
(b). parameter list
(c). return value
(d). Both(a)and(b)
Answer-(d)
Q3. Function class defind
(a). class
(b). function
(c). method
(d). module
Answer-(c)
Q4. Function return statement function return
(a). none
(b). 0
(c). null
(d). Arbitary value
Answer-(a)
Q 5. Recursive function
(a). funtion other function call
(b). A function which calls itself
(c). Both (a)and(b)
(d). None of these
Answer-(b)
Q6. Python id() use
(a). Id() returns the size of object
(b). Id() returns the idenity of the object
(c). Both(a)and(b)
(d). None of above
Answer-(b)
Q7. Function header correct
(a). def fun (a=2,b=3,c)
(b). def fun (a=2,b,c=3)
(c). def fun (a,b=2,c=3)
(d). def fun (a,b,c=3,d)
Answer-(c)
Q8. In which part of memory does the system stores the parameter and local variable of function call ?
(a). heap
(b). stack
(c). Uninitialized data segment
(d). None of above
Answer-(b)
Q9. Which of the following will print the pi value defined in math module?
(a). print(pi)
(b). print(math.pi)
(c). from math import pi print(pi)
(d). from math import pi print(math.pi)
Answer-(c)
Q10. Packages modules import operator python used
(a). * (b). .
(c). -> (d). &
Answer-(b)
Q11. Function define
(a). module
(b). class
(c). Another function
(d). All of the above
Answer-(d)
Q12. Python lambda function
(a). true
(b). false
(c). Lambda is a function in python but user can is it.
(d). None of the above
Answer-(a)
Q13. What is a variable defind outside a function referred to as?
(a). local variable
(b). global variable
(c). static variable
(d). None of above
Answer-(b)
Q14. What is the output of following program
Z=lambda x:x*x
Print(z(6))
(a). 6 (b). 36 (c). 0 (d). error
Answer-(b)
Q15. What is the output of below python program.
(a). a
(b). A
(c). 97
(d). error
Answer-(a)
Q16. How is a function declared in python?
(a). def function function_name():
(b). declared function function_name()
(c). def function_name()
(d). declare function_name()
Answer-(c)
Q17. Which is the correct way of calling function?
(a). function_name()
(b). call function_name()
(c). both(a)and(b)
(d). None of above
Answer-(a)
Q18. Choose the correct option with reference to below python code?
def fn(a):
print(a)
x=90
fn(x)
(a). x is the format argument
(b). a is the actuial argument
(c). fn(x) is the function signature
(d). x is the actual argument
Answer-(d)
Q19. You can also create your own function,these function are called.
(a). built in function
(b). user defined function
(c). py function
(d). None of above
Answer-(b)
Q20. The code block within arry fuction status with a?
(a). ; (b). : :
(c). : (d). %
Answer-(c)
Q21. A return statement with_____agruments.
(a). No
(b). 1
(c). 2
(d). Any
Answer-(a)
Q22. ____ are tge argument passed to a function is correct positional order.
(a). Required argument
(b). keyword argument
(c). Default argument
(d). variable lenth argument
Answer-(c)
Q23. Output of following python code.
Def say Hello():
print(‘Hello world!’)
say Hello()
say Hello()
(a). Hello world!
Hello word!
(b). Hello
Hello
(c). world!
(d). world!
Hello
Answer-(a)
Q24. What is output:-
Def print Max(a,b):
if a>b:
elif a==b:
print(a, ’is equal to’,b)
else:
print(b, ‘is maximum’)
print Max(3,4)
(a). 3
(b). 4
(c). 4 is maximum
(d). None
Answer-(c)
Q25. What is output:-
x=50
def func(x):
print(‘x is’,x)
x=2
print(‘changed local x to’ ,x)
fun(x)
print(‘x is now’ ,x)
(a). x is 50 changed local x to 2 x is now 50
(b). x is 50 changed local x to 2 x is now 2
(c). x is 50 changed local x to 2 x is now 100
(d). None of above
Answer-(a)
Q26. Which is the use of function in python?
A. It are reusable pieces of programs
B. It don’t provide better modularity for application
C. We can’t also create your own functions
D. All of the mentioned
Ans: A
Q27. What is the output of following python code?
def career():
print('Career Bodh!')
career()
career()
A. Career Bodh!
Career Bodh!
B. 'Career Bodh!'
'Career Bodh!'
C. Career
Career
D. None of ABOVE
Ans: A
Q28. What is the output of following code?
def career(message, times = 1):
print(message * times)
career('Hey')
career('World', 4)
A. Hey
WorldWorldWorldWorld
B. Hey
World 4
C. Hey
World,World,World,World
D. None of Above
Ans: A
Q29. What is the output of following python code?
def fun(x, y=5, z=10):
print('x is', x, 'and y is', y, 'and z is', z)
fun(3, 7)
fun(25, z = 24)
fun(z = 50, x = 100)
A. x is 7 and y is 3 and z is 10
x is 25 and y is 5 and z is 24
x is 5 and y is 100 and z is 50
B. x is 3 and y is 7 and z is 10
x is 25 and y is 5 and z is 24
x is 100 and y is 5 and z is 50
C. Both A & B
D. None of Above
Ans: B
Q30. What is the main purpose of a function in Python?
A. To execute a block of code again and again
B. To organize code into manageable units and promote code reuse
C. To perform Logical operations
D. None of Above
Ans: B
Questions which asked O Level Exam Jan 2023 NIELIT:
Q31. What is the output of the below Python code ?
def func(a, b=5, c=10):
print(‘a is’, a, ‘and b is’, b, ‘and c is’, c)
func(13, 17)
func(a=2, c=4)
func(5,7,9)
(A) a is 13 and b is 15 and c is 10
a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9
(B) a is 13 and b is 17 and c is 10
a is 2 and b is 4 and c is 4
a is 5 and b is 9 and c is 7
(C) a is 13 and b is 17 and c is 10
a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9
(D) None of the above
Ans: C
Q32. What is the output of the following Python code ?
def s(n1):
print(n1)
n1 = n1 +2
n2=4
s(n2)
print(n2)
(A) 6 4
(B) 4 6
(C) 4 4
(D) 6 6
Ans: C
Q33. What will be the output of the following Python code ?
d1={“abc”:5,”def”:6,”ghi”:7}
print(d1[0])
(A) abc
(B) 5
(C) {“abc”:5}
(D) Error
Ans: D (def is not used as variable invalid character in indentifier)
Q34. What will be the output of the following Python code ?
def display(b, n):
while n > 0:
print(b,end="")
n=n-1
display('z',3)
A. zzz
B. zz
C. Infinite loop
D. Error
Ans: A
Q35. What is the output of following code?
a=set('abc')
b=set('cdef')
print(a&b)
(A) {‘c’}
(B) {‘a’,’b’,’c’,’d’,’e’,’f’}
(C) {c}
(D) None of these
Ans: A
Q36. What is a variable defined outside a function referred to as ?
A. A static variable
B. A global variable
C. A local variable
D. An automatic variable
Ans: B
Q37. Choose the correct function declaration of fun1() so that we can execute the following two function calls successfully.
fun1(25, 75, 55)
fun1(10, 20)
A. def fun1(**kwargs)
B. def fun1(args*)
C. No, it is not possible in Python
D. def fun1(*data)
Ans: D
Q38. What will be the output of the following Python code ?
def power(x, y=2):
r = 1
for i in range(y):
r = r * x
return r
print power(3)
print power(3, 3)
(A) 212
32
(B) 9
27
(C) 567
98
(D) None of the above
Ans: B
Q39. Which of the following is used to define a block of code in Python language?
A. try
B. Brackets
C. Indentation
D. Catch
Ans: C
Questions which asked O Level Exam July 2022 NIELIT:
Q40. What will be the output of the following Python code ?
def C2F(c) :
return c*9/5+32
print (C2F(100))
print (C2F(0))
(A) 212.0
32.0
(B) 314
24
(C) 567
98
(D) None of the above
Ans: A
Q41. What is the output of the below program ?
def func(a, b=5, c=10) :
print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
(A) a is 7 and b is 3 and c is 10
a is 25 and b is 5 and c is 24
a is 5 and b is 100 and c is 50
(B) a is 3 and b is 7 and c is 10
a is 5 and b is 25 and c is 24
a is 50 and b is 100 and c is 5
(C) a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50
(D) None of the Above
Ans: C
Q41 . If return statements is not used inside the function then function will return---------------------
A. Null
B. 0
C. None
D. Any value
Ans: C
Q42. The part of memory does the system stores the parameter and local variable of function call?
A. Stack
B. Heap
C. Both A & B
D. None of Above
Ans: A
Q43. Which arguments passed to a function in correct positional order?
A. Keyword arguments
B. Required arguments
C. Defaults arguments
D. All of Above
Ans: B
Q44. Which statement that sends back a value from a function?
A. Return
B. 0
C. Input
D. None
Ans: A
Q45. What is the output of round (5.674) ?
A. 6
B. 5
C. 5.6
D. 5.67
Ans: A
Q46. What is output of following code?
Math.floor(-4.4)
A. 4
B. -3
C. -5
D. -4
Ans: C
Q47. In function heading how to arguments specified.
A. Identifier followed by an equal to sign and the default value
B. Identifier followed by the default value within brackets
C. Variables
D. Identifier
Ans: A
Q48. What is the output of below python code?
Import random
Random.choice(4,5,6)
A. Either 4, 5 or 6
B. Only 4, 5
C. Only 6
D. Any integer
Ans: A
Q49. Which function is used to identify the whitespace in given string?
A. Isspace()
B. Space()
C. Both A & B
D. None
Ans: A
Q50. Function call in program by writing in------------------
A. []
B. ()
C. {}
D. None
Ans: B
Q51. Which is true for calling a function?
A. Return function_name()
B. Function_name
C. Function_name()
D. Call function function_name()
Ans:C
Q52 .id() function used in python------------------
A. Id() return the identity of the object
B. Id() return the value of object
C. Id() function is used for object size
D. None
Ans: A
Q53. Which variable defined inside a function?
A. Local variable
B. Auto variable
C. Global variable
D. Fixed variable
Ans: A
Q54. What is output of python below code?
X=5
Eval(‘x**2)
A. 1
B. 25
C. 5
D. None
Ans: B
Q55. What is output of
Random.choice(‘Bodh’)
A. Bodh
B. Either b, o, d or h
C. ‘Bodh’
D. None
Ans: B
Q56. The range(y) function will produce-----------------
A. 0 to y-1
B. 0 to y
C. Y
D. None
Ans: A
Q57. Pi value defined in math module?
A. From math import pi print(pi)
B. Print(math.pi)
C. From math import pi print(math.pi)
D. All of Above
Ans: A
Q58. Random.shuffle() provides which types elements
A. Lists
B. Tuples
C. Set
D. Dictionary
Ans: A
Q59. In a single function call how much keyword argument can be passed
A. 0
B. 1
C. 0 or more
D. A and B Both
Ans: C
Q60. For random library which option is used
A. Import random
B. Import.random
C. Random()
D. All of Above
Ans: A
Q61. The statement
Str=”Career Bodh Sansthan”
Which statement will print ”True” in below:
A. Print(str.isspace())
B. Print(str[2].isspace)
C. Print(str[2].isspace())
D. None
Ans: C
Function MCQ video:





Comments