Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →random.randint(a, b) in Python’s standard library includes both endpoints: a result can be a or b. NumPy’s similarly named functions differ: their upper bound is excluded by default. For a six-sided die, use random.randint(1, 6) in Python, but use np.random.randint(1, 7) or rng.integers(1, 7) with NumPy’s default settings.
Are both ends included in Python’s randint()?
Yes. Python’s standard-library random.randint(a, b) returns an integer N satisfying a <= N <= b. The Python 3.14.8 documentation describes it as an alias for randrange(a, b + 1) (Python documentation: random.randint).
For example, random.randint(1, 6) can return any integer from 1 through 6, including both 1 and 6. This differs from Python’s familiar range(start, stop) convention, where the stop value is excluded: randrange(start, stop, step) chooses from the corresponding range (Python documentation: random.randrange).
Why does NumPy randint() behave differently?
NumPy’s legacy np.random.randint(low, high) includes low but excludes high. Its possible results are in the half-open interval [low, high), so the largest result is high - 1 (NumPy documentation: numpy.random.randint).
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
That means np.random.randint(1, 6) returns values from 1 through 5—not 6. A one-argument call has another easily missed detail: np.random.randint(5) means values from 0 through 4, because the interval is [0, 5).
How to generate integers from 1 through 6
Use the call that matches the API’s endpoint convention:
Rank #2
| API | Endpoint behavior | Call for values 1 through 6 |
|---|---|---|
random.randint(a, b) |
Includes both bounds | random.randint(1, 6) |
np.random.randint(low, high) |
Includes low; excludes high |
np.random.randint(1, 7) |
rng.integers(low, high) |
Includes low; excludes high by default |
rng.integers(1, 7) |
rng.integers(low, high, endpoint=True) |
Includes both bounds | rng.integers(1, 6, endpoint=True) |
For new NumPy code, create a generator with rng = np.random.default_rng() and call rng.integers(...). Its high argument is still exclusive by default; the endpoint=True option makes it inclusive (NumPy documentation: Generator.integers; NumPy beginner guide).
What to check when translating between APIs
- Check which library the function belongs to. The shared name
randintdoes not mean the bounds work the same way. - Check what the upper-bound argument represents. In Python’s standard library it is a possible result; in NumPy’s default calls it is the first value that cannot be returned.
- When translating an inclusive range to NumPy’s default API, add one to the upper bound. For example, Python’s 1-through-6 range becomes NumPy’s
(1, 7). - Use
endpoint=Truewhen you want NumPy’s upper argument to be included explicitly.
NumPy integer dtype note
NumPy’s randint default integer dtype depends on platform sizing; the reference notes that the default corresponds to np.intp sizing since NumPy 2.0. If your code requires a particular fixed-width integer type, specify dtype rather than relying on the platform default (NumPy documentation: numpy.random.randint).
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




