xxxxxxxxxx
# import statement example
# to import standard module math
import math
print("The value of pi is", math.pi)
xxxxxxxxxx
# import only pi from math module
from math import pi
print("The value of pi is", pi)
xxxxxxxxxx
from time import sleep as stop # changes the name of the function to anything you want
print("hi")
stop(3) # works the same as the function without the as
print("bye")
xxxxxxxxxx
Command: import
What is import: Import Statement
Description: The import statement is used to import modules or specific functions, classes, or variables from modules into your Python script.
Example: import math will import the math module, allowing you to use its functions, like math.sqrt(4) to calculate the square root of 4.