WorksheetsPython Functions and Method
Total questions: 15
Worksheet time: 8mins
Which keyword is used for function?
define
fun
def
function
Which of the following items are present in the function header?
function name
parameter list
return value
Both A and B
What is called when a function is defined inside a class?
class
function
method
module
If the return statement is not used inside the function, the function will return:
None
0
Null
Arbitary value
What is a recursive function?
A function that calls other function.
A function which calls itself.
Both A and B
None of the above
Which of the following function headers is correct?
def fun(a = 2, b = 3, c)
def fun(a = 2, b, c = 3)
def fun(a, b = 2, c = 3)
def fun(a, b, c = 3, d)
In which part of memory does the system store the parameter and local variables of a function call?
heap
stack
Uninitialized data segment
None of the above
How is a function declared in Python?
def function function_name():
declare function function_name():
def function_name():
declare function_name():
Which one of the following is the correct way of calling a function?
function_name()
call function_name()
ret function_name()
function function_name()
Which of the following functions is a built-in function in python?
array()
sqrt()
factorial()
print()
What will be the output of the following Python function?
all([2,4,0,6])
Error
True
False
0
What will be the output of the following Python expression?
round(4.5676,2)
4.5
4.6
4.57
4.56
What will be the output of the following Python function?
any([2>8, 4>2, 1>2])
Error
True
False
4>2
What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
2
False
-3
-4
What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
i,ii,iii,iv,v,vi
ii,i,iii,iv,v,vi
ii,i,iv,iii,v,vi
i,ii,iii,iv,vi,v
