You've already forked Curso-lenguaje-python
Restructure content and add notes from HolaMundo
Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
This commit is contained in:
31
python-total/dia_04/10_random.py
Normal file
31
python-total/dia_04/10_random.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
random
|
||||
|
||||
Necesitaremos importar métodos,
|
||||
porque están en una librería llamada random
|
||||
|
||||
Veremos estos métodos:
|
||||
randint()
|
||||
uniform()
|
||||
random()
|
||||
choice()
|
||||
shuffle()
|
||||
"""
|
||||
from random import *
|
||||
|
||||
aleatorio = randint(1, 50)
|
||||
print(aleatorio)
|
||||
|
||||
aleatorio_float = round(uniform(1, 10),4)
|
||||
print(aleatorio_float)
|
||||
|
||||
aleatorio_random = random()
|
||||
print(aleatorio_random)
|
||||
|
||||
colores = ['rosa', 'verde','negro','azul']
|
||||
aleatorio_choice = choice(colores)
|
||||
print(aleatorio_choice)
|
||||
|
||||
numeros = list(range(5,50,5))
|
||||
shuffle(numeros)
|
||||
print(numeros)
|
||||
Reference in New Issue
Block a user