Computer Science

What will the following function print when called ?

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

Python Functions

4 Likes

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.

Answered By

2 Likes


Related Questions