Advertisement
teslariu

bibliotecas

Apr 4th, 2022
1,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Usando la biblioteca time y la funcion time.sleep() hacer un script que pida
  5. # una cantidad de tiempo e imprima una cuenta regresiva hasta terminar
  6. # con la onomatopeya de una explosión:
  7. # ej
  8. # >> Ingrese una cantidad de segundos: 5
  9. # >> 5
  10. # >> 4
  11. # >> 3
  12. # >> 2
  13. # >> 1
  14. # >> ¡BOOOOMMM!!!
  15.  
  16. import time
  17.  
  18. tiempo = int(input("Ingrese una cantidad de segundos: "))
  19. for f in range(tiempo,0,-1):
  20.      print(f)
  21.      time.sleep(1)
  22.  
  23. print("¡BOOOOMMM!")
  24.  
  25. # Script que simula el lanzamiento de dos dados
  26. import random
  27.  
  28. while True:
  29.     print("\nLanzamiento de dados:")
  30.     print(f"Primer dado: {random.randint(1,6)}  Segundo dado: {random.randint(1,6)}")
  31.     opcion = input("Presione cualquier tecla para continuar (o 'x' para salir): ")
  32.     if opcion.lower() == "x":
  33.         print("Hasta luego...")
  34.         break
  35.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement