The random.choice method performs sampling with replacement. This means that the get_ten_random method could return the same question more than once which is not a great user experience.
Using random.sample (part of the standard library since 2.3 so we can for sure assume that it's available), we perform sampling without replacement so that we prevent any possibility of duplicate questions.
The
random.choice
method performs sampling with replacement. This means that theget_ten_random
method could return the same question more than once which is not a great user experience.Using
random.sample
(part of the standard library since 2.3 so we can for sure assume that it's available), we perform sampling without replacement so that we prevent any possibility of duplicate questions.