Bird
Raised Fist0

What is the output of this code?

medium📝 Predict Output Q4 of Q15
Python - Methods and Behavior Definition
What is the output of this code?
def add_five(x):
    return x + 5

result = add_five(10)
print(result)
A5
B10
CNone
D15
Step-by-Step Solution
Solution:
  1. Step 1: Understand the method call and return

    Calling add_five(10) returns 10 + 5 = 15.
  2. Step 2: Print the returned value

    print(result) outputs the returned value 15.
  3. Final Answer:

    15 -> Option D
  4. Quick Check:

    Return value printed = 15 [OK]
Quick Trick: Return value is what print shows when called [OK]
Common Mistakes:
MISTAKES
  • Confusing return with print output
  • Assuming function prints automatically
  • Ignoring return value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes