CBSE Class 12 Computer Science Question 49 of 101

Functions — Question 17

Back to all questions
17
Question

Question 14

What is wrong with the following function definition?

def addEm(x, y, z ): 
    return x + y + z 
    print("the answer is :", x + y + z)
Answer

In the above function definition, the line print("the answer is", x + y + z) is placed after the return statement. In python, once a return statement is encountered, the function exits immediately, and any subsequent code in the function is not executed. Therefore, the print statement will never be executed.