Chapter 5 Python
Chapter 5 Python
1. A __________ is a set of statements that take inputs, do some specific computation and produce output.
2. The main advantage of using functions is that it reduces the size of the python program and induces __________
of code.
a. 4 b. 3 c. 2 d. none
5. __________ functions are the functions that the user create themselves.
8. While defining a function in python a __________ mark the end of function header.
a. 3 b. 4 c. 5 d. 6
10. The _____________ statement is used to exit a function and go back to the place from where the function was
called.
11. The __________ statement can contain expression which gets executed and the value is returned backj to
place where it was called.
a. 2 b. 3 c. 5 d. any
13. Any number of return statements are allowed in a function block, but __________ will be executed when the
program is run.
a. 1 b. 2 c. 3 d. no
15. __________ are the variables used when defining a function, into which the arguments will be copied.
16. ____________ are the values which are passed to any function through the function call statement.
17. Default arguments can be given in a function prototype from ___________ only.
18. We can use ____________ followed by a variable name to define variable length arguments.
20. __________ functions can take any number of arguments as input, but must have only one expression to
evaluate.
23. The recursion ends when the number gets reduced to ______.
a. 1 b. n-1 c. n d. 0
24. Every recursion function must have a __________ condition that stops the recursion.
27. _______________ is a collection of data and functions that act on those data.
31. All integer variables that we use in our python program are object of class __________.
32. All string variables that we use in our python program are object of class __________.
37. Class variable and methods are together known as __________ of a class.
40. Any class members can be accessed by using the object name followed by a _______ operator.
41. The class function must have the first argument named as __________.
42. The ________ parameter is a reference to the current instance of the class.
43. ___________ is the special built - in function that is automatically executed when an object of a class is created
44. In python, there is a special function called ___________ which acts as a constructor.
48. __________ is also a special built in method that gets executed when an object exits from its scope.
50. _____________ removes the memory space allotted to the object by the constructor when the object loses its
scope.
53. Destructor will be executed when the object is deleted using _________ command followed by the object
name.
a. 1 b. 2 c. 3 d. 4
55. The ____________ are used to protect the data from being accessed by unauthorized persons or programs.
56. ____________ members of a class can be accessed only from within the class.
57. _____________ members are denied access from outside the class in which they are declared.
58. __________ members are accessible from outside the class, inside the class and its sub - classes.
59. _____________ members of a class are accessible from within the class and are also available to its sub -
classes.
62. Any attempt to access protected members from within the same class or its derived class will result in an
_________ error.
1. The statement that invokes the function is called __________. (function call statement)
2. In python, we can provide ____________ values for the parameters in the function header statement. (default)
3. _________________ allows the user to call the function with partial arguments or no arguments at all. (Default
arguments)
4. _____________ is a feature that allows a function to receive any number of arguments. (Variable length
arguments)
5. The ___________ function in python is an example for a function that supports variable length arguments.
(print())
6. To import math module in python, the line _________________ is used in the program. (import math)
7. ________ of a number is the product of all the integers from 1 to that number. (Factorial)
8. ____________ and ______________ are the key features of object oriented programming. (Classes, object)
4. Constructor - d. lamda
8. Function that call themselves - h. returns the cosine value of the degree x
9. pow(x,y) - i. __init__()
ANSWER
1. e 2. f 3. g 4. i 5. j 6. c
1. User defined functions need not be defined before they can be used in the program. [False]
2. If all the arguments are provided in the function call statement, the default values are ignored. [True]
3. We can have default values for second parameter from right without giving default value for the first parameter
from right. [False]
4. Lamda functions are defined with keyword def and a function name. [False]
6. Recursion functions make the code look clean and elegant. [True]
9. While calling a class member function, we need to pass value for self argument. [ False]
11. Even if a function takes no argument, self parameter should be defined. [True]