Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 4, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/20280bd222b157147368f4e7e00a0259 to your computer and use it in GitHub Desktop.
Save Fhernd/20280bd222b157147368f4e7e00a0259 to your computer and use it in GitHub Desktop.
Selección de elementos de una colección de forma aleatoria. OrtizOL.
import random as rnd
numeros = [2, 3, 5, 7, 11]
print(rnd.choice(numeros))
print(rnd.choice(numeros))
print(rnd.choice(numeros))
print(rnd.choice(numeros))
print(rnd.choice(numeros))
print('')
rnd.shuffle(numeros)
print(numeros)
print('')
print(rnd.sample(numeros, 3))
print(rnd.sample(numeros, 3))
print(rnd.sample(numeros, 2))
print(rnd.sample(numeros, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment