A web-based Two-Player Number Guessing Game built using Python and Flask.
The application uses Flask sessions to manage game state without requiring a database.
This project is a web version of the classic High–Low Number Guessing Game, designed for two players:
-
Player 1 (Host)
- Sets a secret number
- Defines the maximum number of attempts
-
Player 2 (Guesser)
- Tries to guess the number
- Receives hints: Too High or Too Low
- 🔐 Session-based state management
- 🔄 Real-time feedback for guesses
- 🎚️ Custom difficulty (attempt limits)
- 📜 Guess history tracking
- 🏁 Automatic win and loss detection
- Backend: Python, Flask
- Frontend: HTML5, CSS3
- Templating Engine: Jinja2
Follow the steps below to run the project locally.
- Python 3.x installed
- Git installed
-
Clone the repository
git clone https://github.com/codebyrks/Number_Guessing_Game.git
-
Navigate to the project folder
cd Number_Game -
(Optional) Activate virtual environment
.venv\Scripts\activate # Windows source .venv/bin/activate # Linux / Mac
-
Install dependencies
pip install -r requirements.txt
-
Run the application
python app.py
-
Open in browser
http://127.0.0.1:5000
- Setup Phase:
- Enter a secret number between 1 and 100.
- Set the maximum number of attempts allowed.
- Click "Start Game".
- Guessing Phase:
- Hand the device to Player 2 (or switch roles).
- Enter a guess.
- Review the hint (🔼 Too Low / 🔽 Too High).
- Game ends when:
- 🎉 Number is guessed correctly, or
- ❌ Attempts are exhausted
Number_Game/
├── .venv/ # Virtual environment
├── static/ # CSS and static assets
├── templates/ # HTML templates
├── .gitignore # Git ignore rules
├── app.py # Main Flask application
├── requirements.txt # Project dependencies
└── README.md # Project documentation