Advertisement
Fhernd

aleatorios.py

Jan 19th, 2018
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import random
  2.  
  3. # Inicializa el módulo random():
  4. random.seed()
  5.  
  6. # Genera un número aleatorio:
  7. print(random.random())
  8.  
  9. # Selección aleatoria de un elemento de una lista:
  10. primos = [2, 3, 5, 7, 11]
  11. print(random.choice(primos))
  12.  
  13. # Entero aleatorio entre 1 y 100:
  14. print(random.randint(1, 100))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement