Lambda Functions
Which keyword is used to define a lambda function?
Which Python function is used to apply a lambda function to every element of an iterable?
What is the purpose of filter function in python?
Which of the following is a correct example of a lambda function that takes two input parameters and returns their sum?
Which Python function is used to apply a condition to an iterable and get a filtered output?
What is the output of the following lambda function?
lambda x: x.upper()
Which of the following is a correct example of using the map function with a lambda function to double each element of a list?
what would be the output of the following code?
vegetables = ['brinjal', 'potato', 'tomato', 'palak', 'methi']
filtered_veg = list(filter(lambda x: 't' in x, vegetables))
print(filtered_veg)
What would be the output of the following code?
my_list = [1 ,2 ,3 ,4]
result = list(map(lambda x: x**2 if x%2==0 else x, my_list))
print(result)
what is the output of the following code?
names = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']
reversed_names = list(map(lambda x: x[::-1], names))
print(reversed_names)