random.random() vs random.randint()
random.random() and random.randint() are both Python Random Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. random.random(): Returns a random float in the range [0.0, 1.0). Its syntax is random.random(), and it returns float in [0, 1) random.randint(): Returns a random integer N such that a <= N <= b. Its syntax is random.randint(a, b), and it returns integer Example of random.random(): import random
random.random() # 0.37444887175646646. Example of random.randint(): random.randint(1, 10) # 7 (random int 1-10 inclusive). Read the full references for random.random() and random.randint() to see parameters, edge cases, and example code side by side. Other Random Module APIs worth comparing: random.choice(), random.choices(), random.sample(), random.shuffle(), random.uniform(), random.gauss(). Both belong to the Random Module category in the Python Reference documentation.