Question Detail
Question
What will be the output of the following Python code?
sum = lambda a,b : a+b print (sum(5,6)) print sum(10,30)
Correct Answer
Option C is the correct answer.
Detailed Explanation
The first
print (sum(5,6)) will correctly output 11. However, the second print statement print sum(10,30) uses Python 2 syntax for the print statement without parentheses. In Python 3, print is a function and requires parentheses. Therefore, executing this code in a Python 3 environment (which is implied by the context of the slides often using Python 3 features) would result in a syntax error.
Hint
Check the syntax of the print statements. Is it consistent with modern Python versions?