This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
Retos/Reto #43 - SIMULADOR DE CLIMA [Fácil]/python/alberba.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,43 @@ | ||
import random | ||
|
||
|
||
def ficticio(temperatura:int, prob_lluvia:int, dias:int): | ||
dias_lluvia = 0 | ||
temperatura_min = temperatura | ||
temperatura_max = temperatura | ||
|
||
for dia in range(1, dias + 1): | ||
|
||
print(f"Día {dia}: {temperatura} grados y {prob_lluvia}% de probabilidad de lluvia") | ||
|
||
if temperatura < temperatura_min: | ||
temperatura_min = temperatura | ||
elif temperatura > temperatura_max: | ||
temperatura_max = temperatura | ||
|
||
if prob_lluvia == 100: | ||
dias_lluvia += 1 | ||
temperatura -= 1 | ||
else: | ||
if random.randint(1, 10) == 1: | ||
temperatura += 2 if random.randint(1, 2) == 1 else -2 | ||
|
||
|
||
if temperatura > 25: | ||
|
||
prob_lluvia += 20 | ||
if prob_lluvia > 100: | ||
prob_lluvia = 100 | ||
|
||
elif temperatura < 5: | ||
|
||
prob_lluvia -= 20 | ||
if prob_lluvia < 0: | ||
prob_lluvia = 0 | ||
|
||
print(f"Días lluviosos: {dias_lluvia}") | ||
print(f"Temperatura mínima: {temperatura_min}") | ||
print(f"Temperatura máxima: {temperatura_max}") | ||
|
||
ficticio(24, 100, 365) | ||
|