Full name
random.randint
Library
random
Syntax
random.randint(a, b)
Description
The random.randint function returns a random integer in the closed interval [a, b] extracted from a uniform distribution.
This function is an alias of randrange(a, b + 1)
Parameters
- a: Lower limit of the range from which to extract the random integer.
- b: Upper limit of the range from which to extract the random integer.
Both arguments are required.
Result
The random.randint function returns an integer.
Examples
We can generate a random integer in the closed interval [4, 8] with the following code:
random.randint(4, 8)
7