CBSE Class 12 Computer Science Question 17 of 56

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.

Get the Bright Tutorials app Stuck on a question? Ask Bright Buddy — your AI tutor — for step-by-step help in the app.