A classic command-line Number Guessing Game implemented in Python. The program selects a random secret number between 0 and 100. The player has a limited number of attempts (7 tries) to guess the number. The game provides hints after each incorrect guess, indicating whether the secret number is higher or lower than the input.
- Random Number Generation: The secret number is randomly chosen from 0 to 100 using the
randommodule. - Limited Attempts: The player is given a maximum of 7 attempts.
- Hints: Provides feedback ("higher" or "lower") after each incorrect guess.
- Input Validation: Handles non-integer inputs gracefully.
- Replayability: Allows the user to easily start a new game after one ends.
- Python 3.x installed on your system.
- Save the code as a Python file (e.g.,
guessing_game.py). - Open your terminal or command prompt.
- Run the script using the following command:
python guessing_game.py
- Type 'Sí' or 'Si' when prompted to start the game.
Un clásico Juego de Adivinar el Número de línea de comandos implementado en Python. El programa selecciona un número secreto aleatorio entre 0 y 100. El jugador tiene un número limitado de intentos (7 intentos) para adivinar el número. El juego proporciona pistas después de cada intento incorrecto, indicando si el número secreto es mayor o menor que la entrada.
- Generación de Número Aleatorio: El número secreto se elige al azar entre 0 y 100 usando el módulo
random. - Intentos Limitados: El jugador tiene un máximo de 7 intentos.
- Pistas: Proporciona retroalimentación ("mayor" o "menor") después de cada intento incorrecto.
- Validación de Entrada: Maneja entradas que no son números enteros correctamente.
- Rejugabilidad: Permite al usuario comenzar un nuevo juego fácilmente después de que uno termina.
- Python 3.x instalado en tu sistema.
- Guarda el código como un archivo de Python (por ejemplo,
adivinar_numero.py). - Abre tu terminal o símbolo del sistema.
- Ejecuta el script usando el siguiente comando:
python adivinar_numero.py
- Escribe 'Sí' o 'Si' cuando se te solicite para iniciar el juego.