Python Programming - Functions
Exercise : Functions - General Questions
- Functions - General Questions
21.
What is the purpose of the
min()
function?
Answer: Option
Explanation:
The
min()
function is used to find the minimum value among the elements of an iterable, such as a list.
22.
What will be the output of the following code snippet?
def square(x):
return x ** 2
numbers = [1, 2, 3, 4]
squared_numbers = list(map(square, numbers))
print(squared_numbers)
Answer: Option
Explanation:
The
map()
function applies the square
function to each element in the numbers
list.
23.
How do you define a default value for a function parameter?
Answer: Option
Explanation:
Default values for function parameters are specified using the
parameter=default_value
syntax.
24.
What is the purpose of the
filter()
function?
Answer: Option
Explanation:
The
filter()
function is used to filter elements of an iterable based on whether a function returns True or False.
25.
What does the term "closure" mean?
Answer: Option
Explanation:
A closure is a function object that has access to variables in its lexical scope, even when the function is called outside that scope.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers