9/2/26About 1 minAbout 167 words
Concept: Build-in modules
Python, like any other programming language, has a set of build-in modules that can be used to extend the functionality of the language beyond simple data types and control structures. The complete list of build-in modules can be found in the Python documentation.
In order to use a build-in module, it must first be imported into the script using the import statement. The code below imports the random module, which contains functions that can be used to generate random numbers and other random data.
import random
random_integer = random.randint(1, 10)
print(f"Random integer between 1 and 10: {random_integer}")The example above is perfectly valid. However, it is also possible to import only a specific function from a module using the from statement.
from random import randint
random_integer = randint(1, 10)
print(f"Random integer between 1 and 10: {random_integer}")