Bird
0
0

Which statement correctly imports the calculator module from a package named tools?

easy📝 Conceptual Q2 of 15
Python - Modules and Code Organization
Which statement correctly imports the calculator module from a package named tools?
Aimport tools.calculator
Bfrom calculator import tools
Cimport calculator.tools
Dfrom tools import calculator()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python import syntax for packages

    To import a module inside a package, use import package.module.
  2. Step 2: Check each option

    import tools.calculator uses correct syntax. from calculator import tools reverses package and module. import calculator.tools reverses order. from tools import calculator() incorrectly uses parentheses.
  3. Final Answer:

    import tools.calculator -> Option A
  4. Quick Check:

    Correct import syntax = import package.module [OK]
Quick Trick: Use 'import package.module' to import modules inside packages [OK]
Common Mistakes:
  • Swapping package and module names
  • Adding parentheses in import statements
  • Using incorrect import order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes