DEV Community

Roy
Roy

Posted on

Answer: What is the difference between the random.choices() and random.sample() functions?

The fundamental difference is that random.choices() will (eventually) draw elements at the same position (always sample from the entire sequence, so, once drawn, the elements are replaced - with replacement), while random.sample() will not (once elements are picked, they are removed from the population to sample, so, once drawn…

Top comments (0)