Bird
0
0

Given this package structure:

medium📝 Predict Output Q4 of 15
Python - Modules and Code Organization
Given this package structure:
analytics/
  __init__.py
  stats.py
  report.py
What will be the output of this code?
from analytics import stats
print(stats.mean([1, 2, 3]))

Assuming stats.py has a function mean that returns the average.
AError: Module not found
B2.0
C6
DNone
Step-by-Step Solution
Solution:
  1. Step 1: Understand import and function call

    The code imports the stats module from analytics package and calls mean function with list [1, 2, 3].
  2. Step 2: Calculate mean of the list

    The mean is (1+2+3)/3 = 6/3 = 2.0, so the print outputs 2.0.
  3. Final Answer:

    2.0 -> Option B
  4. Quick Check:

    Function call output = 2.0 [OK]
Quick Trick: Import package.module to access functions inside [OK]
Common Mistakes:
  • Assuming import fails without __init__.py
  • Calculating sum instead of mean
  • Confusing module and function names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes