Skip to content

Commit

Permalink
Merge pull request #5753 from Hugovrc/main
Browse files Browse the repository at this point in the history
Reto #43 - Python
  • Loading branch information
Roswell468 authored Nov 17, 2023
2 parents e1af7e7 + b382ff7 commit 4dbc7a6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Retos/Reto #43 - SIMULADOR DE CLIMA [Fácil]/python/Hugovrc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import random

def simulador_clima(dias: int):
temp_ini = int(input("Digita la temperatura inicial: "))
prob_lluv = int(input("Digita el % de probabilidad de lluvia: "))
dias_luvia = 0
temp_min = 100
temp_max = 0
lluvia = "No"

for dia in range(0, dias):
prob_tem = random.randint(0,10) == 1
aum_o_dis = random.randint(1,2)

if prob_tem:
if aum_o_dis == 1:
temp_ini += 2
else:
temp_ini -= 2
if temp_ini > 25:
if prob_lluv >= 100:
prob_lluv = 100
elif prob_lluv < 100:
restante = 100 - prob_lluv
prob_lluv += restante
else:
prob_lluv += 20
if prob_lluv == 100:
temp_ini -= 1
lluvia = "Si"
if temp_ini < 5:
if prob_lluv <= 0:
prob_lluv = 0
else:
prob_lluv -= 20
if temp_ini > temp_max:
temp_max = temp_ini
if temp_ini < temp_min:
temp_min = temp_ini
if prob_lluv < 100:
lluvia = "No"
if lluvia == "Si":
dias_luvia += 1
print(f"Dia: {dia} , Temperatura: {temp_ini} ,probabilidad de Lluvia: {lluvia, prob_lluv}")
print(f"Temperatura max: {temp_max}")
print(f"Temperatura min: {temp_min}")
print(f"Dias de Luvia: {dias_luvia}")


simulador_clima(10)

0 comments on commit 4dbc7a6

Please sign in to comment.