Consider the following code:
% python
>>> import math
>>> math.sqrt(100)
10.0
>>> from math import sqrt
>>> sqrt(100)
10.0
The math module is the home of the sqrt function.
After we import the math module, we have access to all of the functions in the math module.
When we import the sqrt function, we can access the sqrt function by its name, without having to reference the parent module.
That summarizes the difference between two types of import statements:
import <module>
from <module> import <function_variable_or_class>
The syntax from <module> import *
imports all functions, variables, and classes from a module, so that we can access them by name without referencing the parent module.
For example,
% python
>>> from math import *
>>> sqrt(100)
10.0
>>> pi
3.141592653589793