My requirement is to create a set of random numbers. I know the set size and the random number range. Therefore:
import random
def makeset(lo, hi, ss):
s = set()
while len(s) < ss:
s.add(random.randint(lo, hi))
return s
I realise that certain combinations of lo, hi & ss could result in an impossible task but that's not in scope here.
I've started learning about numpy and wondered if that module offered something that could do this in a single step - i.e., no explicit loop.
But I can't find anything in the documentation. Maybe it's not there.
Any thoughts?