NEW
Font size
WorksheetsPython - Functions
Total questions: 11
Worksheet time: 6mins
Which of the following is a feature of DocString?
Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
All functions should have a docstring
Docstrings can be accessed by the __doc__ attribute on objects
All of the mentioned
Which are the advantages of functions in python?
Reducing duplication of code
Decomposing complex problems into simpler pieces
Improving clarity of the code
All of the mentioned
What are the two main types of functions?
Custom function
Built-in function & User defined function
User function
System function
Where is function defined?
Module
Class
Another function
All of the mentioned
What is called when a function is defined inside a class?
Module
Class
Another function
Method
Which of the following refers to mathematical function?
sqrt
rhombus
add
rhombus
What will be the output of the following Python code?
def cube(x):
return x * x * x
x = cube(3)
print (x)
9
3
27
30
What will be the output of the following Python code?
y = 6
z=lambda x: x * y
print(z(8))
12
36
16
48
What will be the output of the following Python code?
def writer():
title = 'Sir'
name = (lambda x:title + ' ' + x)
return name
who = writer()
who('Arthur')
Arthur Sir
Sir Arthur
Arthur
None of the mentioned
What is a variable defined inside a function referred to as?
A global variable
A volatile variable
A local variable
An automatic variable
If a function doesn’t have a return statement, which of the following does the function return?
int
null
None
An exception is thrown without the return statement
