Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created January 19, 2018 12:18
Show Gist options
  • Save Fhernd/e5475f954bea8d1f8491c10c46991fb7 to your computer and use it in GitHub Desktop.
Save Fhernd/e5475f954bea8d1f8491c10c46991fb7 to your computer and use it in GitHub Desktop.
Generación de números aleatorios en Python.
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