Functions Bookback Mcqs
Functions Bookback Mcqs
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)
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))
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)
22. What is a variable defined outside all the functions referred to as?
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
Answers 9. a
1. d 10. d
2. c 11. b
3. b 12. a
4. a 13. a
5. d 14. b
6. c 15. c
7. a 16. c
8. b 17. d
18. c 23. c
19. a 24. a
20. a, d 25. a
21. b, c 26. b
22. b 27. D
FILL IN THE BLANKS
1. A set of instructions/operations which is a part of a program and can be executed
independently is called a _____.
3. The variable declared outside all the functions is called a _____ variable.
4. The order in which statements are executed during a program run is called the
_____ of execution.
5. A _____ is a file containing Python definitions and statements intended for use in
other Python programs.
6. Functions that do not explicitly return a value return the special object _____.
11. The _____ of a variable is the area of the program where it may be referenced.
12. The terminating condition used for solving a problem using recursion is termed as
the _____ for that problem.
13. A _____ is a subprogram that acts on data and often returns a value.
14. Python names the top level segment (main program) as _____.
15. In Python, program execution begins with first statement of _____ segment.
16. The values being passed through a function-call statement are called _____.
17. The values received in the function definition/header are called _____.
18. A parameter having default value in the function header is known as a _____.
20. _____ arguments are the named arguments with assigned values being passed in
the function call statement.
22. By default, Python names the segment with top-level statements (main program)
as _____.
23. The _____ refers to the order in which statements are executed during a program
run.
24. The default value for a parameter is defined in function _____.
Answers 13. Function
1. function 14. __main__
2. value 15. __main__
3. global 16. argument / actual parameters /
4. flow actual argument
5. module 17. parameter / formal parameter /
6. None formal argument
7. function header 18. default parameter
8. user-defined 19. default
9. recursive 20. keyword
10. Argument / Parameter 21. None
11. scope 22. __main__
12. base class 23. Flow of execution
24. header
TRUE/FALSE QUESTIONS
1. More than one value(s) can be returned by a function in Python.
2. The variable declared inside a function is called a global variable.
3. Once a function is defined, it may be called only once from many different places in
a program.
4. Value returning functions should be generally called from inside of an expression.
5. A local variable having the same name as that of a global variable hides the global
variable in its function.
6. Python passes parameters by reference.
7. Parameters specified within a pair of parentheses in the function definition are the
actual parameters or non-formal parameters.
8. A function in Python is used by invoking it via a function call.
9. Built-in functions are created by users and are not a part of the Python library.
10. The first line of a function header begins with def keyword and eventually ends
with a colon (:).
11. Recursive functions are faster than their iterative counterparts.
12. Recursion is defined as defining anything in terms of itself.
13. Non-default arguments can be placed before or after a default argument in a
function definition.
14. A parameter having default value in the function header is known as a default
parameter.
15. The first line of function definition that begins with keyword def and ends with a
colon (:), is also known as function header.
16. Variables that are listed within the parentheses of a function header are called
function variables.
17. In Python, the program execution begins with first statement of __main__
segment.
18. Default parameters cannot be skipped in function call.
19. The default values for parameters are considered only if no value is provided for
that parameter in the function call statement.
20. A python function may return multiple values.
21. A void function also returns a value i.e., None to its caller.
22. Variables defined inside functions can have global scope.
23. A local variable having the same name as that of a global variable, hides the
global variable in its function.
Answers
1. True
2. False
3. False
4. True
5. True
6. False
7. False
8. True
9. False
10. True
11. False
12. True
13. False
14. True
15. True
16. False
17. True
18. False
19. True
20. True
21. True
22. False
23. True