When the following is executed: data = [1, 2, 3, 4, 5]; filtered = filter(lambda x: x % 2 == 0, data); print(list(filtered)), what is the output?
- [1, 2, 3, 4, 5]
- [1, 3, 5]
- [2, 4]
- [4]
The filter function with the lambda expression filters out the even numbers from data, resulting in the output [2, 4].
Loading...
Related Quiz
- How does the concept of 'system thinking' enhance problem-solving in complex organizational environments?
- Given def process(item): return item * item; items = [1, 2, 3, 4]; result = map(process, items); print(list(result)), what will be the output?
- How does a percentile differ from a quartile in statistical terms?
- How does a Random Forest algorithm reduce variance compared to a single decision tree?
- To add a condition to a SQL query for groupings, the ________ clause is used.