Python Functions MCQ Class 12 CS
Python Functions MCQ Class 12 CS
Q1. The process of dividing a computer program into separate independent blocks of code with specific functionalities is known as _________.
a. Programming
b. Modular Programming
c. More Programming
d. Step Programming
Q2. ____________________ can be defined as a named group of instructions that accomplish a specific task when it is invoked/called.
a. Function
b. Datatype
c. Token
d. Operator
Q3. In a program, a function can be called ____________ times.
a. 2
b. 3
c. 5
d. Multiple times
Q4. Which keyword is used to begin the definition of a function?
a. Define
b. DEF
c. def
d. Def
Q5. Which of the following statement is a function call?
a. call sum( )
b. def sum( )
c. sum( )
d. function sum( )
Q6. Which of the following are advantages of using function in program?
a. It increases readability of program.
b. It increases reusability.
c. It makes debugging easier.
d. All of the above
Q7. Function defined to achieve some task as per the programmer’s requirement is called a ___________
a. user defined function
b. library function
c. built in functions
d. All of the above.
Q8. Functions which are already defined in python is called a ___________
a. user defined function
b. library functions
c. built in functions
d. Both b and c
Q9. Which of the following statement is not true regarding functions?
a. A function definition begins with “define”
b. A function may or may not have parameters.
c. A function may or may not return value.
d. Function header always ends with a colon (:).
Q10. Which of the following statement is outside the function “sum”?
def sum():
a = int(input(“Enter number”))#Statement 1
b = int(input(“Enter number”)) #Statement 2
s = a + b #Statement 3
print(s) #Statement 4
a. Statement 1
b. Statement 2
c. Statement 3
d. Both Statement 3 and Statement 4
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q11. The function can be called in the program by writing function name followed by ____
a. [ ]
b. { }
c. ( )
d. None of the above
Q12. def cal(n1) : What is n1?
a. Parameter
b. Argument
c. Keyword
d. None of the above
Q13. cal(n1) : What is n1?
a. Parameter
b. Argument
c. Keyword
d. None of the above
Q14. Write the output of the following:
def s(n1): print(n1) n2=4 s(n2)
a. 2
b. 3
c. 4
d. Error
Q15. Which of the following statement will execute in last?
def s(n1): #Statement 1 print(n1) #Statement 2 n2=4 #Statement 3 s(n2) #Statement 4
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
Q16. Choose the correct answer:
def s(n1): print(n1) n2=4 s(n2) Statement A : n1 and n2 have same memory Address Statement B : both n1 and n2 are referring to the same value, so they have same identity
a. Statement A is True and Statement B is False
b. Statement A is False and Statement B is True
c. Both the statements are True
d. Both the statements are False
Q17. Write the output of the following :
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
Q18. Consider the following code and choose the incorrect statement.:
def s(n1): print(id(n1)) n2=4 s(n2) print(id(n2))
a. Function name is ‘s’
b. Function ‘s’ is taking one parameter.
c. Both print statement will print the same value.
d. Both print statement will print different value.
Q19. Write the output of the following:
def cal(m,n): if m==n: return m*3 else: return m*2 s = cal(9, 8) print(s)
a. 16
b. 18
c. 27
d. 24
Q20. Write the output of the following:
def cal(m,n): if m==n: return m*3 else: return n*2 s = cal("Amit", "Anuj") print(s)
a. AmitAmitAmit
b. AmitAmit
c. AnujAnujAnuj
d. AnujAnuj
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q21. Write the output of the following:
def fn(n1, n2=7): n1=n1+n2 print(n1) fn(3, 9)
a. 3
b. 9
c. 12
d. 10
Q22. Write the output of the following:
def fn(n1, n2=7): n1=n1%n2 print(n1) fn(3%2, 9%2)
a. 1
b. 0
c. 2
d. 3
Q23. Which of the following function definition header is wrong?
a. def sum(n1, n2, n = 3):
b. def scan(p1, p2 = 4, p3 = 5):
c. def div(p1=4, p2, p3):
d. def mul(p1, n1, m1):
Q24. Functions which do not return any value is called ______
a. default function
b. zero function
c. void function
d. null function
Q25. The ____________ statement returns the values from the function to the calling function.
a. send
b. give
c. return
d. take
Q26. The return statement in function is used to ______
a. return value
b. returns the control to the calling function
c. Both of the above
d. None of the above
Q27. Choose the correct statement
a. We can create function with no argument and no return value.
b. We can create function with no argument and with return value(s)
c. We can create function with argument(s) and no return value.
d. All of the above
Q28. Write the output of the following:
sound() def sound(): print("sound" * 2)
a. sound
b. soundsound
c. NameError : name ‘sound’ is not defined
d. SyntaxError: invalid syntax
Q29. A function may return multiple values using _____
a. List
b. Tuple
c. String
d. Dictionary
Q30. The part of the program where a variable is accessible is known as the __________ of that variable
a. scope
b. module
c. part
d. none of the above
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q31. Which of the following is not the scope of variable?
a. Local
b. Global
c. Outside
d. None of the above
Q32. A variable that is defined inside any function or a block is known as a ____
a. Global variable
b. Local variable
c. Function Variable
d. inside variable
Q33. Fill in the blank so that the output is 9:
a = 9 def sound(): ________ a print(a) sound()
a. local
b. global
c. outer
d. var
Q34. Write the output of the following:
a = 9 def sound(): b = 7 print(a) sound() print(b)
a. 7 7
b. 9 9
c. 7 9
d. Error
Q35. How many built-in functions are used in the following code:
a = int(input("Enter a number: ") b = a * a print(" The square of ",a ,"is", b)
a. 1
b. 2
c. 3
d. 4
Python Functions MCQ Class 12 CS
Q36. Which of the following is not the built-in function?
a. input( )
b. tuple( )
c. print( )
d. dictionary( )
Q37. Which of the following is not the type of function argument?
a. Required argument
b. Keyword argument
c. initial argument
d. default argument
Q38. Write the output of the following:
print("A") def prnt(): print("B") print("C") prnt()
a. A B C
b. B C A
c. A B
d. A C B
Q39. Write the output of the following:
def check(): i = 5 while i > 1: if i //2==0: x = i + 2 i = i-1 else: i = i-2 x = i print (x) check()
a. 3 3
b. 5 3
c. 3 1
d. 3 2
Q40. Which module is to be imported for using randint( ) function?
a. rand
b. random
c. randrange
d. randomrange
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q41. Which of the following number can never be generated by the following code:
random.randrange(0, 100)
a. 0
b. 100
c. 99
d. 1
Q42. Write the output of : print(abs(-45))
a. 45.0
b. -45
c. 45
d. None of the above
Q43. Write the output of : print(max([1, 2, 3, 4], [4, 5, 6], [7]))
a. [1, 2, 3, 4]
b. [4, 5, 6]
c. [7]
d. 7
Q44. Write the output of : print(min(tuple(“computer”)))
a. c
b. o
c. u
d. t
Q45. Choose the incorrect statement.
a. print(pow(2, 3))
b. print(pow(2.3, 3.2))
c. print(pow(2, 3, 2))
d. None of the above
Python Functions MCQ Class 12 CS
Q46. Which of the following return floating point number?
a. print(pow(2, 3))
b. print(pow(2.3, 3.2))
c. print(pow(2, 3, 2))
d. All of the above
Q47. Which of the following statement is correct?
a. A Python standard library consists of a number of modules
b. A Module consists of a number of Python standard libraries
c. Library and modules are alias of each other.
d. None of the above
Q48. Arrange the following from Simple(small) to Complex(big).
Instructions, Functions, Library, Module
a. Instructions, Functions, Library, Module
b. Functions, Instructions, Library, Module
c. Module, Functions, Instructions, Library
d. Instructions, Functions, Module, Library
Q49. A module is save with extension _____________
a. .py
b. .pym
c. .mpy
d. .mps
Q50. Choose the correct statement to import Math module:
a. Import math
b. import math
c. import Math
d. Import Math
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q51. Which of the following is not built-in module in python?
a. math
b. random
c. statistics
d. arithmetic
Q52. In math.ceil(x), what is x here?
a. An Integer
b. A Floating point number
c. An integer or floating point number
d. None of the above
Q53. Write the output of the following :
print(math.floor(-4.5))
a. -4
b. -5
c. 4
d. 5
Q54. Write the output of : print(math.fabs(-6.7))
a. -6
b. 6.7
c. -6.7
d. 7
Q55. ________ function of math module calculates the factorial.
a. fact( )
b. facto( )
c. factorial( )
d. factor( )
Python Functions MCQ Class 12 CS
Q56. Which of the following function return random real number (float) in the range 0.0 to 1.0?
a. random( )
b. randint( )
c. randrange( )
d. None of the above
Q57. Smallest number return by statement random.randrange(2,7) is _________________
a. 2
b. 7
c. -2
d. 0
Q58. Which of the following function is not defined in statistics module?
a. mean( )
b. mode( )
c. median( )
d. sqrt( )
Q59. In order to get a list of modules available in Python, we can use the __________ statement:
a. help(“module”)
b. list(“module”)
c. available(“module”)
d. show(“module”)
Q60. Aman wants to import only sqrt( ) function of math module. Help him to write the correct code.
a. import math
b. from math import sqrt
c. import sqrt from math
d. import sqrt
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
From CBSE Sample Paper – 2021 (Q61-70)
Q61. Which of the following options can be the output for the following code?
import random List=["Delhi","Mumbai","Chennai","Kolkata"] for y in range(4): x = random.randint(1,3) print(List[x],end="#")
a. Delhi#Mumbai#Chennai#Kolkata#
b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi#
d. Mumbai# Mumbai #Chennai # Mumbai
Q62. What will be the output of the following code?
x = 3 def myfunc(): global x x+=2 print(x, end=' ') print(x, end=' ') myfunc() print(x, end=' ')
a. 3 5 5
b. 5 5 5
c. 5 3 5
d. 3 3 5
Q63. Which of the following components are part of a function header in Python?
i. function name ii. return statement iii. parameter list iv. def keyword
a. only i
b. i and iii
c. iii and iv
d. i, iii and iv
Q64. Which of the following function headers is correct?
a. def cal_si(p=100, r, t=2):
b. def cal_si(p=100, r=8, t):
c. def cal_si(p, r=8, t):
d. def cal_si(p, r=8, t=2):
Q65. Which of the following is the correct way to call a function?
a. my_func( )
b. def my_func( )
c. return my_func
d. call my_func( )
Python Functions MCQ Class 12 CS
Q66. What will be the output of the following Python code?
def add (num1, num2): sum = num1 + num2 sum = add(20,30) print(sum)
a. 50
b. 0
c. Null
d. None
Q67. What will be the output of the following code?
def my_func(var1=100, var2=200): var1 += 10 var2 = var2 - 10 return var1+var2 print(my_func(50),my_func())
a. 100 200
b. 150 300
c. 250 75
d. 250 300
Q68. What will be the output of the following code?
value = 50 def display(N): global value value = 25 if N%7==0: value = value + N else: value = value - N print(value, end="#") display(20) print(value)
a. 50#50
b. 50#5
c. 50#30
d. 5#50#
Q69. What is the output of the following code snippet?
def ChangeVal(M,N): for i in range(N): if M[i]%5 == 0: M[i]//=5 if M[i]%3 == 0: M[i]//=3 L = [25,8,75,12] ChangeVal(L,4) for i in L: print(i,end="#")
a. 5#8#15#4#
b. 5#8#5#4#
c. 5#8#15#14#
d. 5#18#15#4#
Q70. What will be the possible outcome of the following code:
import random X =[1,2,3,4] m = random.randint(0,3) for i in range(m): print (X[i],"--",end=" ")
a. 1 —
b. 1 — 2 —
c. 1 — 2 — 3 —
d. All of the above
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q71. Write the output of the following code :
import random for i in range(random.randint(2, 2)): print(i)
a. 0 1
b. 1 2
c. 0 1 2
d. Generate different number
Q72. Write the output of the following code :
import random for i in range(random.randint(2,3)): print("A")
a. A A
b. A A A
c. A A OR A A A
d. Error
Q73. What is the minimum and maximum value of ‘A’ in the following statement.
import random A=random.randint(2,30) print(A)
a. 3 and 30
b. 2 and 30
c. 2 and 29
d. 2 and 28
Q74. Write the output of the following code :
import random A=random.randrange(20) print(A)
a. Any number between 0 to 19 (including both)
b. Any number between 0 to 20 (including both)
c. Any number between 1 to 20 (including both)
d. None of the above
Q75. Write the output of the following code :
import random print(int(random.random( )))
a. Any random number less than 1 and greater than 0
b. Always generate 0
c. Always generate 1
d. Shows Error
Python Functions MCQ Class 12 CS
Q76. Write the output of the following code :
import random print(int(random.random()*5))
a. Always generate 0
b. Generate any number between 0 to 4 (including both)
c. Generate any number between 0 to 5 (including both)
d. None of the above
Q77. Which of the following subject will never printed in following code?
import random L=["English", "Hindi", "Math", "Science", "SST", "CS", "IP"] for i in range(random.randint(1, 6)): print(L[i])
a. CS and IP both
b. English
c. IP
d. English and Hindi both
Q78. What is the minimum and maximum value of ‘v’ in the following statement.
import random v=random.randrange(20)-3 print(v)
a. 0,19
b. 0,17
c. -3,16
d. -3,17
Q79. Which of the following method is not included in random module?
a. Shuffle( )
b. randrange( )
c. randomrange( )
d. uniform( )
Q80. A = random._______________([1,2,3,4,5]). Fill in the blank so that ‘A’ may have any value from the list.
a. shuffle
b. choice
c. uniform
d. None of these
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q81. Functions created by user is called _____________ function
a. Inbuilt
b. Library
c. User defined
d. logical
Q82. Division of large programs into smaller programs. These smaller programs are called ___________.
a. Functions
b. Operators
c. logical programs
d. specific programs
Q83. Use of functions _______________ the size of programs.
a. increases
b. reduces
c. makes no change in
d. None of the above
Q84. We have to import a specific module for using built-in functions?
a. True
b. False
Q85. A function can be called __________ times in a program.
a. 3
b. 7
c. 4
d. any number of
Python Functions MCQ Class 12 CS
Q86. Which of the following is not a type conversion functions?
a. int( )
b. str( )
c. input( )
d. float( )
Q87. Write the output of the following.
print(int( ))
a. Error
b. Any random number
c. 0
d. 1
Q88. Which of the following statement will return error?
print(int("a")) #Statement1 print(str(123)) #Statement2
a. Statement1
b. Statement2
c. Both Statement
d. None of the above
Q89. Write the output of : print(float())
a. 1.0
b. 0.0
c. Any floating number
d. Any integer
Q90. What type of error is returned by following statement?
print(int(“a”))
a. Syntax error
b. ValueError
c. TypeError
d. Name Error
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q91. Write the output of the following: if user entered 7
a=input("Enter age") print(type(a))
a. str
b. int
c. float
d. None of the above
Q92. eval(x) function returns error if x is integer.(T/F)
a. True
b. False
Q93. Write the output of the following:
print(max(2, 5, 4, 8, 29, 24))
a. Error as there should be math.max( )
b. 29
c. 2
d. 2 5 4 8 29 24
Q94. Write the output of the following:
print(min(“Hell”, “Hello”, “he”))
a. Hell
b. he
c. Hello
d. Error
Q95. abs( ) function do not work for float number.(T/F)
a. True
b. False
Python Functions MCQ Class 12 CS
Q96. Write the output of the following.
print(abs(-8))
a. -8
b. 8
c. 8.0
d. None of the above
Q97. len() function returns the length of string only.(T/F)
a. True
b. False
Q98. Write the output of the following :
print(round(34.5671,2)) print(round(34.3631,2))
a. 34.57 34.36
b. 34.56 34.37
c. 34.57 35.36
d. 36.00 34.36
Q99. Write the output of the following:
print(list(i * 2 for i in range(4))) print(list(range(4)))
a. [0, 2, 4, 6] [3]
b. [0, 2, 4, 6] [0, 1, 2, 3]
c. [0, 1, 2, 3] [0, 1, 2, 3]
d. None of the above
Q100. Write the output of : print((range(5)))
a. range(0, 5)
b. 0, 1, 2, 3, 4
c. [0, 1, 2, 3, 4]
d. Error
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q101. Which of the following mathematical function return absolute value of a number?
a. absolute( )
b. abs( )
c. perfect( )
d. absl( )
Q102. Which of the following Python module need to be imported to invoke sin( ) function?
a. math
b. Maths
c. mathematics
d. None of the above
Q103. Which of the following module which need to be imported to invoke randint( ) function?
a. randoms
b. random
c. random( )
d. None of the above
Q104. Which of the following mathematical function return factorial of a number?
a. fact( )
b. facto( )
c. factorial( )
d. fct( )
Q105. Name the function required to check if a string contains only uppercase letters?
a. upper( )
b. isup( )
c. isupper( )
d. iscapital( )
Q106. Which of the following function returns the length of a sequence?
a. len( )
b. length( )
c. lenseq( )
d. None of the above
Q107. Which of the following function is not invoked by math module?
a. ceil( )
b. floor( )
c. sqrt( )
d. mean( )
Q108. Which method of pickle module reads data from a binary file?
a. dump( )
b. load( )
c. read( )
d. reader( )
Q109. Write the output of the following:
def c(x, y): if x % y : return x+5 else: return y+10 print(c(20, 5))
a. 26
b. 15
c. 30
d. 10
Q110. Write the output of the following:
def guess(n="k", a=20, r="t"): return a, n, r t=guess("k", "t", 7) print(t)
a. (‘k’, ‘t’, 7)
b. (‘t’, ‘k’, 7)
c. (7, ‘t’, ‘k’)
d. (‘t’, 7, ‘k’)
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Q111. Write the output of : print(sum(1,2,1))
a. Error
b. 4
c. 2
d. 3
Q112. Write the output of the following:
val = 20 def display (N): val = 25 if N%5 == 0: val = val + N else: val = val - N print(val, end="#") display(70) print(val)
a. 70#20
b. 95#20
c. 75#20
d. 50#20
Q113. Write the output of the following:
def disp(m="A", t = 1): for i in range(t): print(m * 1, end="#") disp('B', 5)
a. B#B#B#B#B#
b. BBBBB
c. BBBBB#
d. #BBBBB#
Q114. Write the output of the following:
def calc(x): r=2*x**2 return r print(calc(3))
a. 18
b. 8
c. 36
d. 9
Q115. Write the output of the following :
def var(var, lst): lst[0] = var k = 33 a = [1, 2, 3] var(k, a) print(a)
a. [1, 2, 3]
b. [33, 1, 2, 3]
c. [33, 2, 3]
d. Error
Q116. Which of the following module is used with binary files?
a. math
b. csv
c. random
d. pickle
Q117. Which of the following module is used for function max( )??
a. math
b. csv
c. random
d. No module is required
Q118. Write the output of the following :
t=(32, 34, 33, 33.5, 41, 44, 33) print(sum(t) + t.count(33))
a. 252.0
b. 253.0
c. 252.5
d. 254
Q119. How many numbers will be printed by the following code:
def fun(n1,n2): for x in range(n1,n2+1): if x%4==0: print(x, end=" ") fun(100,120)
a. 5
b. 6
c. 7
d. 8
Q120. Write the output of the following:
def lst(l1): for x in l1: print(x.lower(),end="---") lst(["MCQ","PAPER"])
a. MCQ—PAPER—
b. mcq—paper—
c. —mcq—paper
d. None of the above
Python Functions MCQ Class 12 CS
Click here to check your performance in Python Functions MCQ
Python Functions MCQ Class 12 CS
Important Links
100 Practice Questions on Python Fundamentals
120+ MySQL Practice Questions
90+ Practice Questions on List
50+ Output based Practice Questions
100 Practice Questions on String
70 Practice Questions on Loops
120 Practice Questions of Computer Network in Python
70 Practice Questions on if-else
40 Practice Questions on Data Structure
Python Functions MCQ Class 12 CS
Computer Science Syllabus 2021-2022.
Informatics Practices Syllabus 2021-2022
Class 12 Computer Science Chapter wise MCQ