Python Libraries
- Categories Python Libraries
Q. 1 Name the default Python attributes that are displayed with dir() funtions
Ans. _builtins_, _cached_, _doc_, _file_, _loader_, _name_, _package_, _spec_
Q.2 What is _all_ ? What is its uses?
_init_.py file in the package directory contains a list named _all_. It is a list of modules that should be imported when the statement from import* is encountered
e.g. _all_ = [, , —–]
If _all_ is defined inside a module it controls what all is imported from a module
When from import*statement is encountered
Q.3 What is the difference between absolute import and relative import?
Absolute import | Relative import |
The exact location of an object in the package is defined using dot notation | The position of the object is defined relative to the current directory |
From < package-name>, < subpackage-name>, < module –name>, import< object> | From ..import< subpackage-name,< modulename > |
Q.4 Name the Python Library modules which need to be imported to invoke the following functions
Coil()
Randint()
Ans. math and random
Q. 5 Name the Python Library modules which need to be imported to invoke the following functions
Load()
Pow()
Ans. pickle
Math
Q. 6 Name the modules to which the following functions belong
Uniform
Fabs
Ans.random
math