Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries

The Python import keyword is used to import modules in the current session. The modules which need to be imported must be installed on the local computer or a remote computer. All objects defined in the module can be used in the current session after importing it in the current session. To use an object of the module, the syntax starts with module name followed by dot (.) and object name.


#import module
import ModuleName

#use object of a module


In the below example, the math module is imported in the current session. The math module contains an object called pi which is used in the current session to calculate the area of a circle.

import math

radius = 1
pi = math.pi
area = pi*(radius)**2


The output of the above code will be:


❮ Python Keywords