Advertisement
teslariu

cuenta_regresiva

Feb 9th, 2022
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Hacer un script que pida un numero e implemente una cuenta regresiva
  5. # desde ese nro hasta cero
  6. # ayuda: función time.sleep()
  7. # el tiempo debe ser mayor a cero, entonces voy a validar con isdecimal
  8. import time
  9.  
  10. while True:
  11.     numero = input("Ingrese una cantidad de segundos: ")
  12.     if numero.isdecimal():
  13.         numero = int(numero)
  14.         break
  15.     else:
  16.         print("Debe ingresar un nro entero mayor a cero")
  17.        
  18. # cuenta regresiva
  19. for tiempo in range(numero,0,-1):
  20.     print(tiempo)
  21.     time.sleep(1)
  22. print("BOOMMMMM")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement