This project contains two versions of the Guess the Number game:
main.py: The basic version, implementing the core guessing functionality.main_stretch.py: The stretch version, supporting multiple rounds and personal best tracking.
- The program randomly selects an integer between 1 and 100.
- The player enters a guess, and the program responds with "Too high!", "Too low!", or "Correct!".
- When the correct number is guessed, the program displays the total number of attempts.
- After each round, the player is asked whether to play again.
- The program keeps track of and displays the best (fewest) number of guesses across rounds.
- If a new personal best is achieved, a special message is shown.
- Make sure Python 3 is installed.
- Open a terminal and navigate to the project directory.
- To run the basic version:
python3 main.py
- To run the stretch version:
python3 main_stretch.py
I'm thinking of a number between 1 and 100.
Take a guess: 50
Too low!
Take a guess: 75
Too high!
Take a guess: 63
Correct! You guessed the number in 3 tries.
I'm thinking of a number between 1 and 100.
Take a guess: 42
Too high!
Take a guess: 21
Too low!
Take a guess: 33
Correct! You guessed the number in 3 tries.
New personal best: 3 guesses!
Play again? (y/n): y
...
Thank you for playing!
- If a non-integer is entered, the program will prompt for a valid input.
- The stretch version supports multiple rounds and best score tracking.