Bird
0
0

Why does a method with a return statement sometimes return None even if it has calculations inside?

hard📝 Conceptual Q10 of 15
Python - Methods and Behavior Definition
Why does a method with a return statement sometimes return None even if it has calculations inside?
ABecause calculations are wrong
BBecause return always returns None
CBecause it lacks an explicit return statement
DBecause print is used instead of return
Step-by-Step Solution
Solution:
  1. Step 1: Understand default return behavior

    If a method does not have a return statement, Python returns None by default.
  2. Step 2: Differentiate from other causes

    Return does not always return None; calculations alone don't cause None; print does not affect return value.
  3. Final Answer:

    Because it lacks an explicit return statement -> Option C
  4. Quick Check:

    No return means method returns None [OK]
Quick Trick: No return statement means method returns None [OK]
Common Mistakes:
  • Thinking return always returns None
  • Confusing print with return
  • Assuming calculation affects return without return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes