Created
June 4, 2018 12:39
-
-
Save Fhernd/20280bd222b157147368f4e7e00a0259 to your computer and use it in GitHub Desktop.
Selección de elementos de una colección de forma aleatoria. OrtizOL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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