-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5753 from Hugovrc/main
Reto #43 - Python
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
Retos/Reto #43 - SIMULADOR DE CLIMA [Fácil]/python/Hugovrc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |