How are the following statements different from one another?
a)import math b)From math import
Answers
Answer:
Import math:
will import the math module. Any functions that you use would have to be used as math.sqrt, math.ceil, etc.
from math import *
will import all functions from math. Any functions that you use can be used as sqrt, ceil, etc.
##Analogy
Think of math as your refrigerator.
If you import the refrigerator (import math), you will need to open the refrigerator door to take out the food and bottles, like refrigerator.food, refrigerator.bottle.
But if you import everything inside the refrigerator (from math import *), then that means you can freely use the food and bottles as they have already been taken from the refrigerator and outside it (so, no need for refrigerator.food, just use food).
hope it helps...
thank you :)
Explanation:
Hope this will help you.