Function || Multiple Choice Questions || Class 12
1. A function in Python begins with which keyword?
(a) void
(b) return
(c) int
(d) def
2. Name the statement that sends back a value from a function.
(a) print
(b) input
(c) return
(d) None
3. Functions that do not return any value are known as:
(a) fruitful functions
(b) void functions
(c) library functions
(d) user-defined functions
4. A variable created or defined within a function body is classified as:
(a) local
(b) global
(c) built-in
(d) instance
5. Which of the following arguments works with implicit values that are used if no value is provided?
(a) keyword
(b) required
(c) variable-length
(d) default
6. Which values are used by the functions to communicate information back to the caller?
(a) local
(b) global
(c) return
(d) random
7. What is the output of the program given below?
x = 50
def func (x) :
x = 2
func (x)
print ('x is now', x)
(a) x is now 50
(b) x is now 2
(c) x is now 100
(d) Error
8. Which is the most appropriate definition for recursion?
(a) A function that calls itself
(b) A function execution instance that calls another execution instance of the same function
(c) A class method that calls another class method
(d) An in-built method that is automatically called
9. Fill in the line of code for calculating the factorial of a number:
def fact (num):
if num == 0 :
return 1
else:
return
(a) num*fact(num-1)
(b) (num-1)*(num-2)
(c) num*(num-1)
(d) fact(num)*fact(num-1)
10. Which of the following statements is false about recursion?
(a) Every recursive function must have a base case.
(b) Infinite recursion can occur if the base case isn't properly mentioned.
(c) A recursive function makes the code easier to understand.
(d) Every recursive function must have a return value.
11. What is the output of the following snippet?
def fun (n):
if (n > 100):
return n - 5
return fun (fun (n+11))
print (fun (45))
(a) 50
(b) 100
(c) 74
(d) Infinite loop
12. What happens if the base condition isn't defined in recursive programs?
(a) Program gets into an infinite loop
(b) Program runs once
(c) Program runs n number of times, where n is the argument given to the function
(d) An exception is thrown
13. What is the default return value for a function that does not return any value explicitly?
(a) None
(b) int
(c) double
(d) null
14. Which of the following items are present in the function header?
(a) function name only
(b) both function name and parameter list
(c) parameter list only
(d) return value
15. Which of the following keywords marks the beginning of the function block?
(a) func
(b) define
(c) def
(d) function
16. 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
17. Pick one the following statements to correctly complete the function body in the given code snippet.
def f(number):
# Missing function body
print(f(5))
(a) return "number"
(b) print(number)
(c) print("number")
(d) return number
18. Which of the following function headers is correct?
(a) def f(a = 1, b):
(b) def f(a = 1, b, c = 2):
(c) def f(a = 1, b = 1, c = 2):
(d) def f(a = 1, b = 1, c = 2, d):
19. Which of the following statements is not true for parameter passing to functions?
(a) You can pass positional arguments in any order.
(b) You can pass keyword arguments in any order.
(c) You can call a function with positional and keyword arguments.
(d) Positional arguments must be before keyword arguments in a function call.
20. Which of the following function calls can be used to invoke the below function definition?
def test(a, b, c, d)
(a) test(1, 2, 3, 4)
(b) test(a = 1, 2, 3, 4)
(c) test(a = 1, b = 2, c = 3, 4)
(d) test(a = 1, b = 2, c = 3, d = 4)
21. Which of the following function calls will cause Error while invoking the below function definition?
def test(a, b, c, d)
(a) test(1, 2, 3, 4)
(b) test(a = 1, 2, 3, 4)
(c) test(a = 1, b = 2, c = 3, 4)
(d) test(a = 1, b = 2, c = 3, d = 4)
22. What is a variable defined outside all the functions referred to as?
(a) A static variable
(b) A global variable
(c) A local variable
(d) An automatic variable
23. What is a variable defined inside a function referred to as
(a) A static variable
(b) A global variable
(c) A local variable
(d) An automatic variable
24. Carefully observe the code and give the answer.
def function1(a):
a= a + '1'
a = a * 2
>>> function1("hello")
(a) indentation Error
(b) cannot perform mathematical operation on strings
(c) hello2
(d) hello2hello2
25. What is the result of this code?
def print_double(x):
print(2 ** x)
print_double(3)
(a) 8
(b) 6
(c) 4
(d) 10
26. What is the order of resolving scope of a name in a Python program?
(L: Local namespace, E : Enclosing namespace, B: Built-In Namespace, G: Global namespace)
(a) BGEL
(b) LEGB
(c) GEBL
(d) LBEG
27. Which of the given argument types can be skipped from a function call?
(a) positional arguments
(b) keyword arguments
(c) named arguments
(d) default arguments
2 should be b
ReplyDeletereturn is correct
DeleteYes.
Deletehwllo
ReplyDeleteHi
DeleteThis is not the sumit Arora questions !
ReplyDeleteWhoso ever it is jilust learn it
Deletehi
ReplyDeletethanks bro
ReplyDeleteWelcome 😊
Deleteis recursion there for term 1 syllab?
ReplyDeleteupload sumita arora's solution
ReplyDeleteI have uploaded it. Please check on website.
DeleteHi😊
ReplyDeletehi yo
ReplyDeleteYes.
Deleteoo soriya
ReplyDelete??
DeleteThank you
ReplyDeleteWelcome : )
Deleteman you are the best !! I LOVE YOUU!!!
ReplyDeleteThankyou : ) !! Love you to !!!
DeleteThanks
ReplyDeleteWelcome : )
Deletethese questions does'nt match with the new version of the book
ReplyDeleteWhich one.
DeleteMCQ compare to book and web page now matching
ReplyDeleteNow= not
ReplyDeleteThese are practice question.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )