What is the purpose of the map function in Python?
a) To filter elements from a list
b) To perform a specified operation on each element of a list (Correct)
c) To reduce a list to a single value
d) To apply a condition to elements of a list
Which of the following is true about the map function?
a) It always returns a list
b) It can only be used with numerical data
c) It takes a function and an iterable as arguments (Correct)
d) It can only be used with strings
What does the filter function do in Python?
a) It maps a function to an iterable
b) It reduces a list to a single value
c) It removes elements from a list based on a condition (Correct)
d) It converts an iterable to a dictionary
Which of the following is true about the filter function?
a) It returns a new list with elements that satisfy a condition (Correct)
b) It modifies the original list
c) It always returns an empty list
d) It requires a sorting operation on the list before using it
What is the purpose of the reduce function in Python?
a) To perform an operation on each element of a list
b) To convert an iterable to a dictionary
c) To reduce a list to a single value by applying a specified function (Correct)
d) To remove elements from a list based on a condition
Which module should be imported to use the reduce function in Python?
a) math
b) collections
c) itertools
d) functools (Correct)
Which of the following is true about the reduce function?
a) It always returns a list
b) It can only be used with strings
c) It applies a function to a pair of elements in the list until only one element is left (Correct)
d) It requires the elements of the list to be of the same type
What happens when the map function is applied to an empty list?
a) It raises an error
b) It returns an empty list (Correct)
c) It returns a list with None as the only element
d) It returns the original list unchanged
How does the filter function handle an empty list?
a) It raises an error
b) It returns an empty list (Correct)
c) It returns a list with None as the only element
d) It returns the original list unchanged
Which of the following is true about the reduce function?
a) It always returns an empty list
b) It raises an error when applied to an empty list
c) It returns the original list unchanged
d) It raises an error when applied to a list with a single element (Correct)