Advertisement
teslariu

adivinar

Sep 6th, 2022
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Script que implementa el juego de adivinar un numero del 1 al 100
  5. # La compu responde menor o mayor ante cada numero ingresado y se debe
  6. # intentar adivinarlo con un maximo de 7 intentos
  7. import random
  8.  
  9. numero = random.randint(0,100)
  10.  
  11. for intento in range(7,0,-1):
  12.     n = int(input("Ingrese un entero de 0 a 100: "))
  13.    
  14.     if n > numero:
  15.         print("El nro buscado es menor")
  16.        
  17.     elif n < numero:
  18.         print("El nro buscado es mayor")
  19.        
  20.     else:
  21.         print("Has encontrado el nro.... Felicitaciones")
  22.         break
  23.    
  24.     print(f"Te restan {intento - 1} intentos\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement