👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
Example :
|
import statement
We can use any Python source file as a module by executing an import statement in another source Python file.
When the interpreter encounters an import statement, it imports the module if the module is present in the search path. Search path — this is a list of directories that the interpreter looks for to import a module. For example, to import the calc.py module, we need to place the following command at the top of the script:
|
Output:
12
statement from import
The Python from statement allows you to import certain attributes from a module. from .. import .. has the following syntax:
|
|
Output:
[’BPF’,’ LOG4’, ’NV_MAGICCONST’,’ RECIP_BPF’, ’Random’,’ SG_MAGICCONST’, ’SystemRandom’,’ TWOPI’, ’WichmannHill’,’ _BuiltinMethodType’, ’_MethodType’,’ __all__’, ’__builtins__’,’ __doc__’, ’__file__’,’ __name__’, ’__package__’,’ _acos’, ’_ceil’, _e _cos’, ’,’ _exp’, ’_hashlib’,’ _hexlify’, ’_inst’,’ _log’, ’_pi’,’ _random’, ’_sin’,’ _sqrt’, ’_test’,’ _test_generator’, ’_urandom’, ’_warn’,’ betavariate’, ’choice’,’ division’, ’expovariate’,’ gammavariate’, ’gauss’,’ getrandbits’ , ’getstate’,’ jumpahead’, ’lognormvariate’,’ normalvariate’, ’paretovariate’,’ randint’, ’random’,’ randrange’, ’sample’,’ seed’, ’setstate’,’ shuffle’, ’ triangular’, ’uniform’,’ vonmisesvariate’, ’weibullvariate’]
Code snippet illustrating built-in Python modules:
|
Output:
5.0 3.14159265359 114.591559026 1.0471975512 0.909297426826 0.87758256189 0.234143362351 24 3 0.401533172951 88.4917616788 True 1461425771.87 1970-01-06amp-youtube data-videoid = nfYZL-uFm-c layout = responsive width = 665 height = 374>
This article prev left by Gaurav Shrestha . Please post comments if you find something wrong or if you would like to share additional information on the topic discussed above. If you like Python.Engineering and would like to contribute, you can also write an article and mail it to [email protected] See your article appearing on the Python.Engineering homepage and help other geeks.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Python modules, check other Angular by Google JavaScript library-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Python modules
- Deutsch Python modules
- Français Python modules
- Español Python modules
- Türk Python modules
- Русский Python modules
- Português Python modules
- Polski Python modules
- Nederlandse Python modules
- 中文 Python modules
- 한국어 Python modules
- 日本語 Python modules
- हिन्दी Python modules
Singapore | 2023-04-01
I was preparing for my coding interview, thanks for clarifying this - Python modules in Python is not the simplest one. I am just not quite sure it is the best method
New York | 2023-04-01
I was preparing for my coding interview, thanks for clarifying this - Python modules in Python is not the simplest one. Checked yesterday, it works!
Boston | 2023-04-01
Maybe there are another answers? What Python modules exactly means?. I am just not quite sure it is the best method
Shop
Latest questions