Q. Mark created following directory structure for his module namely chk:


chk
|
|__work.py
|__test
        |__newwork.py


He has copied the folder's link to site-packages folder of Python but still the following command is giving error:


>>> import chk
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import chk
ModuleNotFoundError: No module named 'chk'
>>> 


(a) What is the possible reason of above error?
(b) Rectify above problem.
(c) After rectifying, write command to import work module of above shown chk package
(d) After rectifying, write command to import newwork module of above shown chk package


Answer :-


(a) Reason is that python does not know the path of ‘chk’ package.

(b) Package ‘chk’ must contain ‘__init__.py’ module and also sub-package must contain ‘__init__.py’ module.

(c) >>> import chk.work

(d) >>> import chk.test.newwork

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post