2 Functions Lesson 2
2 Functions Lesson 2
(a) A set of instructions/operations which is a part of a program and can be executed independently to
do a specifictask is called a....
(e) A . s a file containing Python definitions and statements intended for use in other Python
programs.
(f) Functionsthat do not explicitly return a value return the special object...
(8) The first line of a function definition is called.
(h) The function which is written by the programmer as per his/her requirements is known as .
function.
(i) A function is said to be . . . .. if it calls itself.
G) .. act as a means of communication between the called and calling function.
(k) The... .. of a variable is the area of the program where it may be referenced.
for
(1) The terminating condition used for solving a problem using recursion is termed as the.
that problem.
(m) . . keyword is used to define a function.
(n) Function name must be followed by . . . and
2. State whether the following statements are True or False.
(a) More than value(s) can be returned by a function in Python.
one
(b) The variable declared inside a
function is called a global variable.
cOnce a function is
defined, it may be called only
(a) value returning functions should
once from
many different places
in a program.
be generally called from inside of an expression.
e A Ocal variable having the
function.
same name as that of a global variable hides the global variable in its
() Python passes parameters by reference.
8) Parameters specified within a pair of parentheses in the function definition are the actual
parameters
2.50 or non-formal parameters.
is used by invoking it
Gnction in
A
Python via a function call.
((h) i n functions are created by users and are not a part of the Python library.
i r s t line of a function header begins with def keyword and eventually ends with a colon ()
Recursive functions iterative counterparts.
dre raster than their
acrsion is defined as defining anything in terms of itself.
(e) Which of the following arguments works with implicit values that are used if no value is
(iv) default
provided?
(i) keyword ii) required (ii) variable-length
that do notreturn V None
F u n c t i o n s
any value are known as:
(c) i) fruitful functions
(ii) void functions
(ii) library functions
(iv) user-defined functions
Aariable created or defined within a function body is classified as:
(i) local (ii) global (ii) built-in (iv) instance
e)
ahich of the following arguments works with implicit values that are used if no value is provided?
() keyword (ii) required (ii) variable-length (iv) default
a/hich values are used by the functions to communicate information back to the caller?
(i) local (ii) global (ii) return (iv) random
of the program given below?
(a)What is the output
x = 50 padle
x = 2
func (x)
print ('x is now x)
()xis now 50 (ii) x is now 2 (ii) x is now 1000 (iv) Error
(h) Which is the most appropriate definition for recursion?
() A function that calls itself
(i) A function execution instance that calls another execution instance of the same function
(ii) A class method that calls another class method
(iv) An in-built method that is automatically called
Fill in the line of code for calculating the factorial of a number:
else:
return
(i) (num-1) * (num-2)
() num*fact(num-1)
(ii) num*(num-1) (iv) fact(num) "fact(num-1)
G) Which of the following statements is false about recursion?
must have base case.
() Every recursive function a
e ak
(a) function (b) value (c) global (d) flow (e) module
f) None (8) function header (h) user-defined ) recursive
) Arguments/Parameters (k) scope (1) base class
(n) 0,:tcolon) (m) def
(a) True (b) False (c) False (d) True (e) True (f) False a) False (h) True
() Faise 0) True (k) False () True (m) True
olce Qucstions (Mcos)
(a) (iv) (b) (ii) (c) (i) (d) (i) (e) (iv) (f) (ii) (h) (i)
)(iv) (k) (i) (1) (6)