Lambda Function in Python MCQs Exercise I


Ques 1 Lambda Function


Which of the following is false about the lambda function?
  a) lambda function is also known as anonymous function.
  b) lambda keyword are used create a lambda function.
  c) There must be atleast one variable pass in the function
  d) All of these.


c is the correct option





Ques 2 Lambda Function


What is the output of the following Python Code?


li=[1,2,3,4,5,6,7,8,9,10]
filter_list=list(filter(lambda a: a%2==0,li))
print("Filter List:",filter_list)

  a) Filter List: [1, 3, 5, 7, 9]
  b) Filter List: [2, 4, 6, 8, 10]
  c) Filter List: [1,2,3,4,5,6,7,8,9,10]
  d) Filter List: [1,2,3,4,5,6,7,8,9,11]


b is the correct option





Ques 3 Lambda Function


What is the output of the following Python Code?


from functools import reduce
li=[1,2,3,4,5,6,7,8,9,10]
red=reduce((lambda a,b: a*b),li)
print("Result:",red)

  a) Result: 3328800
  b) Result: 3628600
  c) Result: 3629800
  d) Result: 3628800


d is the correct option





Ques 4 Lambda Function


What is the output of the following Python Code?


li=[1,2,3,4,5,6,7,8,9,10]
new_list=list(map(lambda a: a**2,li))
print("New List:",new_list)

  a) New List: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
  b) New List: [1, 2, 9, 16, 25, 36, 49, 64, 81, 100]
  c) New List: [1, 4, 9, 16, 25, 36, 64, 81, 100, 121]
  d) New List: [4, 9, 16, 25, 36, 49, 64, 81, 100]


a is the correct option