Consider module to be the same as code library. A file containing a set of functions you want to include in your application. There are different types of modules in python.
- Import
- From……… Import
- Renaming
Table of Contents
Import Module in python 3.10
The import statement is use to import all the functionality of one module into another. We can import multiple modules with a single import statement, but a module is loaded once regardless of the number of times, it has been imported into our file. Create the module named as file.py
Import module1,module2,…….. module n
Examples:
1. import platform
x = platform.system()
print(x)
2. import datetime
x = datetime.datetime.now()
print(x)
From… import Module in python 3.10
Instead of importing the whole module into the namespace, python provides the flexibility tom import only the specific attributes of a module. This can be done by using from? Import statement.
From < module-name> import <name 1>, <name 2>..,<name n>
Examples:
1. from sklearn.preprocessing import LabelEncoder
2. from sklearn.model_selection import train_test_split
3. from sklearn.preprocessing import StandardScaler
4. from sklearn.preprocessing import StandardScale
5. from sklearn.linear_model import LinearRegression
6. from sklearn.linear_model import Ridge, Lasso
7. from sklearn.metrics import mean_squared_error
Renaming modules in python 3.10
Python provides us the flexibility to import some module with a specific name so that we can use this name to use that module in our python source file.
Import <module-name> as <specific-name>
Examples:
1. import numpy as np
2. import pandas as pd
3. import matplotlib.pyplot as plt
4. import seaborn as sns
5. import warnings
6. %matplotlib inline
7. warnings.filterwarnings('ignore')
Summary :
In this article we saw different modules in python 3.10 so about this section you have any query then free to ask me
Also see: