What is the import statement in Python?

The import statement is used to import external modules in Python. These modules add to the language’s functionality in some specified area. A few keywords are involved in the import statement:

Keyword 1: import

Primarily, an import statement comprises of the import keyword,​ followed by the name of the module to be imported.

import math
square_root = math.sqrt(9)
print(square_root)

Keyword 2: from

The from keyword is used to import only a very specific part of a module.

from math import sqrt
square_root = sqrt(9)
print(square_root)

To import all of the ​functions from the module, the * character can also be used.

from math import *
square_root = sqrt(9)
print(square_root)

Keyword 3: as

The as keyword is used to give a custom name to the module for usage within the program.

import math as M
square_root = M.sqrt(9)
print(square_root)

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved