Curso-lenguaje-python/python-total/dia_04/10_random.py
Manuel Vergara f4e9797c4b Restructure content and add notes from HolaMundo
Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
2023-05-20 09:36:26 +02:00

32 lines
520 B
Python

"""
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)