Professional Documents
Culture Documents
Answer =
Answer =
A doc-string is just a regular Python triple-quoted string that is the first thing in a function body/ a
module/ a class. When executing a function body (or a module/ class), the doc-string doesn't do
anything like comments, but Python stores it as part of the function documentation. This
documentation can later be displayed using the help() function.
So, even though doc-strings appear like comments (no execution), they are different from comments
For example:-
Answer =
Package: A package is a directory that contains sub-packages and modules in it along with some
special files such as __init__.py.
While A module is a file with some Python code and is saved with a .py extension.
Q. What is a library? Write procedure to create own library in
Python.
Answer =
A Python library is a reusable chunk of code that is used in program/script using import command. A
package is a library if it is install-able or gets attached to site-packages folder of Python installation.
Answer =
Answer =
In order to import a package using import command, the packages and its contents must be
attached to site-package folder of Python installation as this is the default place from where
Python interpreter import Python library and packages. So, in order to import our package with
import command in our programs, we must attach it to site package folder of Python installation.
Q. What is the importance of site-packages folder of Python
installation?
Answer =
In order to import a package using import command, the packages and its contents must be
attached to site-package folder of Python installation as this is the default place from where
Python interpreter import Python library and packages. So, in order to import our package with
import command in our programs, we must attach it to site package folder of Python installation.
Q. What is PYTHON PATH variable? What is its significance?
Answer =
PYTHONPATH is the variable that tells the interpreter where to locate the module files imported into
a program. Hence, it must include the Python source library directory and the directories containing
Python source code. You can manually set PYTHONPATH, but usually, the Python installer will
preset it.
Answer =
In sys. order.
Answer =
The dir() function returns a list of all the attributes within in an object - these could be either data
values or methods, and the list includes private and magic methods.
(i)log()
(ii) pow()
Answer =
Math module
Answer =
After importing a module, to access one of the function, you have to specify the name of the
function, separated by dot. This format is called dot notation.
Answer =
Because it may lead to name clashes. If you use plain import <module>, no problem occur.
Answer =
Python standard library is very extensive that offers many built in functions. Python standard
library is by default available, you don't have to import it separately.
Answer =
while from <module> import statement import the function which is present in given module.
Example :-
(i)
import math
a = 144
print( math.sqrt(a) )
Output :-
12.0
>>>
(ii)
Output:-
12.0
>>>