Syntax

Python Import a Module Syntax

In Python, import a module: imports a module or a name from it — from math import sqrt

Quick Answer

Syntax
from math import sqrt
PythonSyntax

Import a Module

Code example
from math import sqrt

Imports a module or a name from it.

Learn More

How to import a module in Python

  1. Open your Python file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Python Import a Module Syntax

Use from math import sqrt.

Related Syntax References

Frequently asked questions

What is the Python syntax for import a module?

Use this pattern: from math import sqrt

Can I copy this Python code example?

Yes. Use Copy code and adapt the example to your program.

Is this Python syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify