Bird
0
0

Which of the following is a correct way to create an empty __init__.py file in a package folder?

easy📝 Syntax Q12 of 15
Python - Modules and Code Organization
Which of the following is a correct way to create an empty __init__.py file in a package folder?
ACreate a file named <code>__init__.py</code> with no content
BCreate a file named <code>init.py</code> with no content
CCreate a file named <code>__init__.py</code> with a main() function
DCreate a file named <code>__init__.txt</code> with no content
Step-by-Step Solution
Solution:
  1. Step 1: Identify the exact filename required

    The file must be named exactly __init__.py to mark the folder as a package.
  2. Step 2: Confirm that it can be empty

    The file can be empty; no code is required inside for it to work.
  3. Final Answer:

    Create a file named __init__.py with no content -> Option A
  4. Quick Check:

    Empty __init__.py file = B [OK]
Quick Trick: Filename must be exactly __init__.py [OK]
Common Mistakes:
  • Using wrong filename like init.py or __init__.txt
  • Adding unnecessary code inside when empty is fine
  • Confusing with main.py or other files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes