From be86e7517423f338b58df611bf9ed37739fcb8fb Mon Sep 17 00:00:00 2001 From: pyRamsd Date: Mon, 27 Nov 2023 17:30:35 -0500 Subject: [PATCH] Retos #43 - python --- .../python/pyramsd.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "Retos/Reto #43 - SIMULADOR DE CLIMA [F\303\241cil]/python/pyramsd.py" diff --git "a/Retos/Reto #43 - SIMULADOR DE CLIMA [F\303\241cil]/python/pyramsd.py" "b/Retos/Reto #43 - SIMULADOR DE CLIMA [F\303\241cil]/python/pyramsd.py" new file mode 100644 index 0000000000..6d49922268 --- /dev/null +++ "b/Retos/Reto #43 - SIMULADOR DE CLIMA [F\303\241cil]/python/pyramsd.py" @@ -0,0 +1,44 @@ +import random + + +def weather_simulator(temperature: int, rain: int, days: int): + + rainy_days = 0 + min_temp = temperature + max_temp = temperature + + for day in range(1, days + 1): + + print(f"Día {day}: {temperature} grados y {rain}% de probabilidad de lluvia") + + if rain == 100: + rainy_days += 1 + + if temperature < min_temp: + min_temp = temperature + + if temperature > max_temp: + max_temp = temperature + + if random.randint(1, 10) == 1: + temperature += 2 if random.randint(1, 2) == 1 else -2 + + if temperature > 25: + rain += 20 + if rain > 100: + rain = 100 + + elif temperature < 5: + rain -= 20 + if rain < 0: + rain = 0 + + if rain == 100: + temperature -= 1 + + print(f"Días lluviosos: {rainy_days}") + print(f"Temperatura mínima: {min_temp}") + print(f"Temperatura máxima: {max_temp}") + + +weather_simulator(24, 100, 365) \ No newline at end of file