Python from Keyword
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.
#import section/object from module from ModuleName import SectionName #use section/object of a module SectionName(parameters)
In the example below, 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:
❮ Python Keywords