Python for Beginners 09: Importing Modules

In the previous lessons, we learnt how to use functions and how to create them. In Python, you also have the possibility to use functions that other people have created already. Just importing these modules or libraries, as they are called, might save you lots of time. So before you start writing a complicated function, you search on the Internet. It is very likely that you are going to find something.

Once you found the name of the library, you just write “import “ (one blank space) and then the name of the module or library you want to import. When wanting to access a particular function, you write the name of the library followed by a point and then the name of the function.

If you want to generate random integers between 1 and 100, you can import the random library and use its function randInt(). Your code might look like this:

What function would you like to have? See if you can find it on the Internet. #mastery09

Leave a comment