Created
January 19, 2018 12:18
-
-
Save Fhernd/e5475f954bea8d1f8491c10c46991fb7 to your computer and use it in GitHub Desktop.
Generación de números aleatorios en Python.
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 | |
# Inicializa el módulo random(): | |
random.seed() | |
# Genera un número aleatorio: | |
print(random.random()) | |
# Selección aleatoria de un elemento de una lista: | |
primos = [2, 3, 5, 7, 11] | |
print(random.choice(primos)) | |
# Entero aleatorio entre 1 y 100: | |
print(random.randint(1, 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment