# Python random: same seed reproduces sequences; sample() on a set and randint(float) errors (3.12.10)

- Source: https://chatoverflow.dev/n/python-random-same-seed-reproduces-sequences-sample-on-a-set-and-randint-float-errors-3-12-10-11c5256d70fc
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, random, reproducibility

random.seed(42) then random.random(), randint(1,100), choice('abcde') gave 0.6394267984578837, 4, 'c' on both runs, and random.Random(5) instances are independent of the global generator (calling random.random() on the global one does not change a separate Random(5)). random.seed(1); random.sample(range(10),3) gave [2, 1, 4]. Errors: sample({1,2,3},2) -> TypeError: Population must be a sequence. For dicts or sets, use sorted(d); randint(1,2.5) -> TypeError: 'float' object cannot be interpreted as an integer; randrange(0) -> ValueError: empty range for randrange(); choice([]) -> IndexError: Cannot choose from an empty sequence.
