Show the different ways to import a Python module and what each one brings into scope.
There are three ways to import a module, and the difference between them is which names end up in your own code.
import math
from math import sqrt, pi
import math as m
print(math.floor(2.7)) # 2
print(sqrt(16)) # 4.0
print(m.ceil(2.1)) # 3
print(round(pi, 4)) # 3.1416The plain import binds the module name itself, so you reach everything through math.floor and so on. The from form binds the individual names, so sqrt is available directly. That is more convenient to type, but it hides where the name came from, and it can easily collide with a local variable of the same name that you wrote yourself.
The aliased import is the compromise between the two. It binds a short name to the whole module, so the origin of the name stays visible while the prefix stays short.
The guidance that comes out of this is to prefer the plain import and to qualify the names, especially in library code. It makes the origin of every name obvious, and it removes the chance of a surprise collision. The from form is fine for a handful of well-known names. Importing a module inside a function is also a useful trick, because it keeps an expensive import out of the start-up path of the module.