Difference: random(), randint(), randrange()
| Function | What it does | Example | Output example |
|---|---|---|---|
random() |
Returns a float in [0.0, 1.0). | random.random() |
0.6723 |
randint(a, b) |
Returns an int in [a, b] (inclusive). | random.randint(1, 10) |
7 |
randrange(start, stop, step) |
Returns an int from range(start, stop, step). | random.randrange(1, 10, 2) |
3 |