CBSE Class 12 Computer Science Question 73 of 103

Working with Functions — Question 6

Back to all questions
6
Question

Question 5

What will the following function print when called ?

def addEm(x, y, z):
    return x + y + z
    print(x + y + z)
Answer

The function addEm prints nothing when called.

Explanation
  1. The function addEm(x, y, z) takes three parameters x, y, and z.
  2. It returns the sum of x, y, and z.
  3. Since the return statement is encountered first, the function exits immediately after returning the sum. The print statement after the return statement is never executed. Therefore, it prints nothing.