- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Import module in Python
In this article, we will learn about all the methods by which we can import modules in Python 3.x. Or earlier. The import statement is used to include all the dependencies/modules needed to execute the code.
The most common way :
Syntax
import < module name >
Example
import math print(math.log10(100))
Output
2.0
The efficient way :
Syntax
from <module name> import <function name>
Example
from math import pi print(math.pi)
Output
3.14159265358979
Importing all functions from the module
Syntax
from math import *
Example
from math import * print(math.log10(100))
Output
2.0
Specifying an alias name to the import module
Syntax
import <module name> as <alias name>
Example
import math as m print(m.log10(100))
Output
2.0
Conclusion
In this article, we learned about importing external modules and libraries in Python 3.x. Or earlier.
- Related Articles
- Import a module in Python
- How I can dynamically import Python module?
- How can import python module in IDE environment available in tutorialspoint?
- How to import a single function from a Python module?
- How to import a Python module given the full path?
- What are the “best practices” for using import in a Python module?
- How to import and export a module/library in JavaScript?
- Accessing import parameters passed to a function module in SAP ABAP
- The import Statements in Python
- colorsys module in Python
- Keyboard module in Python
- Fraction module in Python
- struct module in Python
- Pygorithm module in Python
- How to import Matplotlib in Python?

Advertisements