Advertisement
teslariu

contador2

Dec 16th, 2021
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # hacer un script que simule un contador en forma regresiva empezando
  5. # desde un valor ingresado por consola
  6. # ej:
  7. # >>> Ingrese un número entero mayor a cero: 5
  8. # >>> 5
  9. # >>> 4
  10. # >>> 3
  11. # >>> 2
  12. # >>> 1
  13. # >>> ¡BOOOMMM!
  14. # AYUDA: biblioteca time, función sleep ---> time.sleep
  15. #
  16. # TICKET 1: validar que el tiempo ingresado sea válido
  17.  
  18.        
  19. import time     # biblioteca para hacer el contador
  20.        
  21. while True:
  22.     tiempo = input("Ingrese un número entero mayor a cero: ")
  23.     if tiempo.isdecimal():
  24.         tiempo = int(tiempo)
  25.         for i in range(tiempo,0,-1):
  26.             time.sleep(1)
  27.             print(i)
  28.         print("¡BOOOMMM!")
  29.         break
  30.     print(f"Error: {tiempo} no es un entero mayor a cero")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement