File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Retos/Reto #27 - CUENTA ATRÁS [Media]/python Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Crea una función que reciba dos parámetros para crear una cuenta atrás.
3+ - El primero, representa el número en el que comienza la cuenta.
4+ - El segundo, los segundos que tienen que transcurrir entre cada cuenta.
5+ - Sólo se aceptan números enteros positivos.
6+ - El programa finaliza al llegar a cero.
7+ - Debes imprimir cada número de la cuenta atrás.
8+ """
9+
10+ import time
11+
12+ def countdown (start : int , delay : int ) -> None :
13+ """
14+ Prints a countdown from a given starting number down to zero, pausing
15+ for a specified number of seconds between each printed value.
16+
17+ Args:
18+ start (int): Positive integer that specifies where the countdown begins.
19+ delay (int): Positive integer indicating the number of seconds to wait
20+ between each printed number.
21+
22+ Raises:
23+ TypeError: If `start` or `delay` is not an integer.
24+ ValueError: If `start` or `delay` is less than or equal to zero.
25+
26+ Returns:
27+ None
28+ """
29+ if not isinstance (start , int ) or not isinstance (delay , int ):
30+ raise TypeError ("Error. Solo se aceptan valores enteros para el inicio o el tiempo." )
31+
32+ if start <= 0 or delay <= 0 :
33+ raise ValueError ("Error. El numero de inicio o espera debe ser mayor a 0." )
34+
35+ for i in range (start , - 1 , - 1 ):
36+ print (i )
37+ time .sleep (delay )
38+
39+
40+ if __name__ == "__main__" :
41+ countdown (10 , 2 )
You can’t perform that action at this time.
0 commit comments