Question 8
Back to Exercise
What is the output of the following Python program?
grade = lambda m: "pass" if m >= 40 else "fail"
print(grade(40), grade(39), list(map(grade, [90, 12])))
- A fail fail ['pass', 'fail']
- B pass pass ['pass', 'pass']
- C SyntaxError
- D pass fail ['pass', 'fail'] Correct
Correct Answer: Option D
40 >= 40 is True. The lambda can be passed to map like any function.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!