Difference between "from...import" and "import"

Just wondering what s the difference between from ‘a’ import ‘b’ and import ‘a’.

eg:
from string import lower
import pandas as pd

When you type just import you are importing the whole module, and for use a specific function from it you have to specify the name of the module before the function.
for instance:

import math
math.sqrt(16) #return 4

otherwise you can import the single function from it and omit the name of the module when you call it

from math import sqrt
sqrt(16) #return 4
2 Likes