Python Programming - Functions
Exercise : Functions - General Questions
- Functions - General Questions
56.
How can you create a generator function?
Answer: Option
Explanation:
A generator function in Python is created by using the
yield
keyword to produce a series of values over time.
57.
What is the purpose of the
functools.reduce
function?
Answer: Option
Explanation:
The
functools.reduce
function in Python is used to apply a function cumulatively to the items of an iterable, reducing the iterable to a single cumulative result.
58.
What is the purpose of the
getattr
function?
Answer: Option
Explanation:
The
getattr
function in Python is used to get the value of a named attribute of an object.
59.
What is the purpose of the
functools.partialmethod
?
Answer: Option
Explanation:
The
functools.partialmethod
in Python is used to create partial methods with default arguments, similar to functools.partial
for functions.
60.
How does the
locals
function differ from globals
?
Answer: Option
Explanation:
The
locals
function returns the local namespace, while globals
returns the global namespace.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers