forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouredev.py
45 lines (30 loc) · 1.06 KB
/
mouredev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import random
def weather_simulator(temperature: int, rain: int, days: int):
rainy_days = 0
min_temperature = temperature
max_temperature = 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_temperature:
min_temperature = temperature
if temperature > max_temperature:
max_temperature = 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_temperature}")
print(f"Temperatura máxima: {max_temperature}")
weather_simulator(24, 100, 365)