Why is it Necessary to Import Modules?



If there are modules that come built in with the language, why do we even need to import them? Why isn’t it already available on the database?

Thank you

How does Python know where to import math from?

Hi @minhto3083476154,

Modules aren’t part of the core language, they just extend it by giving you additional functionality. Since anyone can develop a Python module, it’s impossible to have all of them be part of the core language (what if two people write different modules with the same name?). Also, having every module available at runtime would slow down the Python interpreter.