Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # implementar un contador en forma regresiva que simule la explosion
- # de una bomba:
- # Ej:
- # >>> Ingrese un tiempo: 3
- # >>> 3
- # >>> 2
- # >>> 1
- # >>> BOOOMMM
- # usar time.sleep()
- import time
- def ingresar():
- while True:
- tiempo = input("Ingrese el tiempo: ")
- if tiempo.isdecimal() and int(tiempo) != 0:
- return int(tiempo)
- print("Error, debe ingresar un numero entero mayor a cero")
- def explotar(tiempo):
- for t in range(tiempo,0,-1):
- print(t)
- time.sleep(1)
- print("BOOOM")
- tiempo = ingresar()
- explotar(tiempo)
- ## Script que pide adivinar un numero entre 1 y 100. Tiene 5 oportunidades
- import random
- numero = random.randint(1,100)
- acertado = False
- print("Adivine un numero entre 1 y 100. Tiene 5 oportunidades")
- for i in range(5):
- print(f"{i+1}ยบ oportunidad")
- n = int(input("Ingrese un nro: "))
- if n == numero:
- print("Ha acertado. Felicitaciones...")
- acertado = True
- break
- elif n > numero:
- print("Elija un numero menor...")
- else:
- print("Elija un numero mayor...")
- if not acertado:
- print("Ha perdido...")
- print(f"El nro buscado era {numero}")
Advertisement
Add Comment
Please, Sign In to add comment