🎯 Biblioteca Random em Python

Em poucas palavras

Biblioteca para geração de números pseudoaleatórios, com funções para fixar e recuperar a semente (seed, getstate, setstate), sortear inteiros (randrange, randint), escolher e embaralhar sequências (choice, shuffle, sample) e gerar decimais entre 0 e 1 (random).


📝 Notas e Desenvolvimento

Esta biblioteca Python é amplamente utilizada para lidar com números aleatórios (ou pseudoaleatórios neste caso).

As principais funções são:

random.seed(a=None) # Set the seed using a value
random.getstate() # Returns an object capturing the current internal state of the generator. This object can be passed to setstate()
random.setstate(state) #_state_ should have been obtained from a previous call to `getstate()
random.randrange(start, stop[, step]) # Create a list of values
random.randint(a, b) # Returns an integer value between a and b
random.choice(seq) # Returns a random item from the list
random.shuffle(_x_) # Shuffles the sequence
random.sample(population, k, *, counts=None) # returns a sample
random.random() # Returns a random decimal value between 0 and 1

:: Referência :: random — Gerar números pseudoaleatórios — Documentação Python 3.11.2


📚 Referências e Fontes

🔗 Conexões do Cofre

🌐 Referências Externas

💬 Citações Diretas