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].
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *