Bird
0
0

You have a package folder named tools with modules calc.py and format.py. You try to run:

medium📝 Debug Q14 of 15
Python - Modules and Code Organization
You have a package folder named tools with modules calc.py and format.py. You try to run:
from tools import calc
print(calc.multiply(4, 5))

But get ModuleNotFoundError. What is the most likely cause?
AFunction multiply does not exist in calc.py
BMissing <code>__init__.py</code> file in the tools folder
CSyntax error in import statement
DPython version is too old
Step-by-Step Solution
Solution:
  1. Step 1: Understand ModuleNotFoundError cause

    This error often means Python does not recognize the folder as a package.
  2. Step 2: Check package structure requirements

    Without __init__.py, Python won't treat 'tools' as a package, causing import failure.
  3. Final Answer:

    Missing __init__.py file in the tools folder -> Option B
  4. Quick Check:

    __init__.py missing causes ModuleNotFoundError [OK]
Quick Trick: Always add __init__.py to package folders [OK]
Common Mistakes:
  • Assuming function absence causes ModuleNotFoundError
  • Ignoring package folder structure
  • Blaming Python version without checking files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes