Python Tutorial 14: How to import a python library into a python program

How to import a python library into a python program?

Python as libraries that add functionality to the basic interpreter of Python,

In order to reduce the size of the program and also to maximise the performance., they are not loaded into the basic interpreter by default. To import a python library into a python program. we simply use the import statement.


Import python library


import random

This will import the random library into the python program.


The “random” here represent the import library random and the “randint” is a method available from the random library. This comment is actually calling the randint method from the random library with arguement 0 and 1000.


For a full list of libraries available from python, please refer to the python library from the following website:



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.