Bird
0
0

What happens if two functions with the same name exist in a custom module and you import that module?

hard📝 Conceptual Q10 of 15
Python - Modules and Code Organization
What happens if two functions with the same name exist in a custom module and you import that module?
ABoth functions are available with different names automatically
BPython raises an error about duplicate functions
CPython ignores the second function silently
DThe last defined function overwrites the previous one
Step-by-Step Solution
Solution:
  1. Step 1: Understand function definitions in a module

    Python reads the module top to bottom; later definitions overwrite earlier ones.
  2. Step 2: Effect on importing module

    Only the last function with that name is available after import.
  3. Final Answer:

    The last defined function overwrites the previous one -> Option D
  4. Quick Check:

    Duplicate function names = last one wins [OK]
Quick Trick: Duplicate names overwrite previous definitions [OK]
Common Mistakes:
  • Expecting error on duplicate function names
  • Thinking both functions are accessible automatically
  • Assuming Python ignores duplicates silently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes