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


The Python from keyword is used to import a specified section from a module. The modules from which the section need to be imported must be installed on the local computer or a remote computer. The imported section of the module can be used in the current session using its name only and passing the required parameter if has any.

Syntax

#import section/object from module
from ModuleName import SectionName

#use section/object of a module
SectionName(parameters)

Example:

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

from math import pi

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

print(area)

The output of the above code will be:

3.1416

❮ Python Keywords