This is a simple guessing game where the user is asked to guess a number between 1 and 10. The game generates a random number and the user has three chances to guess the number. If the user's guess is too low, the game outputs "Your guess is too low". If the user's guess is too high, the game outputs "Your guess is too high". If the user correctly guesses the number, the game outputs "Good job! You guessed my number in x guesses!", where x is the number of guesses it took the user to correctly guess the number. If the user fails to correctly guess the number in three tries, the game outputs "Nope. The number I was thinking was x", where x is the randomly generated number.
• Python 3 • random library
- Install Python 3 if not already installed.
- Open the terminal or command prompt.
- Navigate to the directory where the code is stored.
- Type python ‘file-name.py’ in the terminal or command prompt, where "filename" is the name of the code file.
- Follow the prompts in the game.
This program is a simple script and does not require any contributions.
This program is open-sourced and free to use for any purpose.
This program is created by xzebcex.
The code above is a simple number guessing game written in Python. The game generates a random number between 1 and 10, and the player is given three attempts to guess the correct number. If the player's guess is too low or too high, the game informs them. If the player correctly guesses the number, the game will congratulate them and indicate how many attempts it took. If the player is unable to guess the correct number within three attempts, the game will display the correct number.