Bird
0
0

This __init__.py file contains:

medium📝 Debug Q7 of 15
Python - Modules and Code Organization
This __init__.py file contains:
import os
def start():
print("Starting")

When importing the package, you get an error: IndentationError. What is the problem?
AThe function start() is not indented properly
BYou cannot import os in __init__.py
CFunctions cannot be defined in __init__.py
DMissing parentheses in print statement
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation rules in Python

    Function bodies must be indented consistently.
  2. Step 2: Identify cause of IndentationError

    If print("Starting") is not indented under def start():, error occurs.
  3. Final Answer:

    The function start() is not indented properly -> Option A
  4. Quick Check:

    Indentation error = Fix function body indent [OK]
Quick Trick: Indent function bodies inside __init__.py correctly [OK]
Common Mistakes:
  • Thinking import os causes error
  • Believing functions disallowed in __init__.py
  • Confusing print syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes