The randint()
function in Python is part of the random
module, and it is used to generate a random integer within a specified range. The function takes two arguments: the start and the end of the range (inclusive).
Syntax:
import random
random.randint(a, b)
a
: The lower bound (inclusive).b
: The upper bound (inclusive).
Example:
import random
# Generate a random integer between 1 and 10 (both inclusive)
random_number = random.randint(1, 10)
print(random_number)
In this example, random.randint(1, 10)
will generate a random number between 1 and 10, inclusive.