AllInfoHub Logo

AllInfoHub – MCQ Practice

Modules and Packages – Multiple Choice Questions (MCQs)

  1. 37. If a module `my_module` has `__all__ = ['func1', 'var_a']`, what will be imported by `from my_module import *`?

    • A. All names in the module
    • B. Only `func1` and `var_a`
    • C. All names except those starting with '_'
    • D. Nothing
  2. 38. How can you find the location of an installed module?

    • A. Using the `locate` command in the terminal
    • B. Using the `inspect` module or the `__file__` attribute of the module
    • C. By checking the `sys.path` manually
    • D. By looking in the Python installation directory
  3. 39. What is the purpose of namespace packages in Python?

    • A. To allow splitting a single logical package across multiple directories
    • B. To improve import speed
    • C. To hide internal modules
    • D. To create platform-specific packages
  4. 40. How are namespace packages typically created?

    • A. By including an `__init__.py` file in each directory
    • B. By omitting the `__init__.py` file in each directory
    • C. By using a special declaration in a setup file
    • D. It's not possible to create namespace packages explicitly
  5. 41. What is the order in which Python searches for modules?

    • A. Built-in modules -> `sys.path`
    • B. Current directory -> Built-in modules -> `sys.path`
    • C. `sys.path` -> Built-in modules -> Current directory
    • D. Online repositories -> Local directories -> Built-in modules
  6. 42. What is the purpose of the `reload()` function in the `importlib` module?

    • A. To import a module for the first time
    • B. To force Python to reload a module that has already been imported
    • C. To uninstall a module
    • D. To check if a module is installed
  7. 43. When might you need to use `reload()`?

    • A. When a module's source code has been changed after it was initially imported
    • B. To improve the performance of module loading
    • C. To resolve import errors
    • D. To change the alias of an imported module