A library refers to a collection of modules that together cater to a specific type of needs or application. Module is a file(.py file) containing variables, class definitions statements, and functions related to a particular task. Python modules that come preloaded with Python are called standard library modules.
Creating our module
We will be creating a module named tempConversion.py that converts values from F to C and vice-versa.
Now save this python file and the module is created. This module can be used in other programs after importing it.
Importing a module
In python, in order to use a module, it has to be imported. Python provides multiple ways to import modules in a program :
- To import the entire module :
- To import only a certain portion of the module :
from module_name import object_name
- To import all the objects of the module :
from module_name import *
Using an imported module
After importing the module, we can use any function/definition of the imported module as per the following syntax:
This way of referring to the module’s object is called dot notation.
If we import a function using
from, there is no need to mention the module name and the dot notation to use that function.
Example 2 : Importing particular components of the module :
Python standard library functions
The python interpreter has a number of functions built into it that are always available. To use these built-in functions of python directly call the functions, like
function_name(). Some built-in library functions are : input(), int(), float() etc
Number entered = 5 Octal conversion yields 0o5 Hexadecimal conversion yields 0x5 5
- Create and Import modules in Python
- How to Dynamically Load Modules or Classes in Python
- Basics of Discrete Event Simulation using SimPy
- twitter-text-python (ttp) module - Python
- Creating and updating PowerPoint Presentations in Python using python - pptx
- OS Module in Python with Examples
- Python calendar module | formatmonth() method
- Draw Circle in Python using Turtle
- Python | Writing to an excel file using openpyxl module
- os.walk() in Python
- Python statistics | median()
- OS Path module in Python
- Part of Speech Tagging with Stop words using NLTK in python
- Monkey Patching in Python (Dynamic Behavior)
- Python | randint() function
- How to clear screen in python?
- Get similar words suggestion using Enchant in Python
- Getting started with Scikit-image: image processing in Python
- Reading an excel file using Python
- Writing to an excel sheet using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.