random.randint()
random.randint() is a Python function in the Random Module category. Returns a random integer N such that a <= N <= b. The syntax is random.randint(a, b). Parameters: a, b — inclusive bounds. Returns: Integer. A typical example: random.randint(1, 10) # 7 (random int 1-10 inclusive). A close sibling is random.random(), which returns a random float in the range [0.0, 1.0). A close sibling is random.choice(), which returns a random element from a non-empty sequence. A close sibling is random.choices(), which returns a list of k random elements with optional weights (allows duplicates). A close sibling is random.sample(), which returns a list of k unique elements chosen without replacement. More about this category: Random number generation — random, randint, choice, shuffle, sample. Related Random Module entries: random.random(), random.choice(), random.choices(), random.sample(), random.shuffle(), random.uniform(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.