Importing and using Python modules

Modules are like preset functions within Python. For example if I want to get the square root of a number but I don’t want to do it in the babylonian way or whatever, I can just import a math function that does all the nasty work for me. In this case I’d need to type “import math” at the very start of my code. Then use the square root module (math.sqrt), here’s an example:

Importing and using Python modules

Importing and using Python modules

CC BY 4.0 Importing and using Python modules by tywins is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.