The way you're doing it is sound. However, you could use the more intuitive nonzero
function:
random.sample(visited.nonzero(), k)
EDIT:
As to the second question in you comment, you can inverse the "zeroness" of you array: visited==0
. You get:
random.sample((visited==0).nonzero(), k)