DEV Community

Discussion on: How do you do random?

Collapse
 
rhymes profile image
rhymes • Edited

Python:

import random
random.randint(0, 10)

Ruby:

rand(11)

Go:

import "math/rand"

func main() {
    rand.Intn(11)
}

None of these are cryptographically secure though

Collapse
 
zeerorg profile image
Rishabh Gupta

Python has a cryptographically secure library called "secrets", which I use a lot :-P

Collapse
 
rhymes profile image
rhymes

Yeah secrets is very useful and has a clear API