Import Modules in python you need to use the import keyword along with the desired module name.
When interpreter comes across an import statement, it import the module to your current program.
You can use the function inside a module by using a dot(.) operator along with the module name.
PROGRAM
Import math pie = math. pi print("The value of pi is : ", pie)
output The value of pi is : 3.141592653589793
IMPORT PYTHON BUILT-IN MOUDULE
In this example, the built-in ‘random’ module is imported in python using the import statement. The rand int function from the ‘random’ module is then utilized to generate a random integer between 1 to 10, and the result is printed we can also import a file in python by using import statement.
Program
# Import the ‘random’ module, which is a built- in module for random number generation
import random
# Generate a random number between 1 and 10 random _number = random. rand int (1, 10)
print (“Random Number:”, random_ number)
output Random Number: 5