Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anurag1101/python_guess_game
A simple console-based game in Python that generates a random score between 1 and 1000 and tracks the highest score achieved, saving it to a text file for persistent storage. Play to beat your own records!
https://github.com/anurag1101/python_guess_game
import library oops python python3
Last synced: about 8 hours ago
JSON representation
A simple console-based game in Python that generates a random score between 1 and 1000 and tracks the highest score achieved, saving it to a text file for persistent storage. Play to beat your own records!
- Host: GitHub
- URL: https://github.com/anurag1101/python_guess_game
- Owner: Anurag1101
- Created: 2024-10-01T16:33:11.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-13T07:09:14.000Z (2 days ago)
- Last Synced: 2024-11-13T07:33:53.658Z (2 days ago)
- Topics: import, library, oops, python, python3
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Guess Game
Welcome to the **Python Guess Game!** This fun game challenges you to beat the high score by generating a random score each time you play. If you score higher than the current high score, you set a new `record!`
## Table of Contents:
- ### Features
- ### Installation
- ### Usage
- ### How It Works
- ### Future Improvements## Features:
- **Random Score Generation:** Each round, the game generates a random score between 1 and 1000.
- **High Score Tracking:** The highest score is saved in main.txt and updated whenever a new high score is achieved.
- **Replay Option:** After each round, players can choose to play again or exit the game.
- **File Handling & Error Handling:** The game handles file reading and writing operations gracefully, ensuring a seamless experience.## Installation
### Clone the repository:
git clone https://github.com/your-username/python_guess_game.git### Navigate to the directory:
cd python_guess_game
### Ensure you have `Python 3.x` installed.
## Usage:
1. Run the game with the following command: `python guess_game.py`
2. Follow the on-screen prompts to play the game. You’ll see your score, and if it's higher than the high score, it will be saved as the new high score.
## How It Works:
1. **Generating a Random Score:** The `play_game()` function generates a score between 1 and 1000 using Python's `random` module.
2. **Retrieving High Score:** The `get_high_score()` function reads the high score from `main.txt` if it exists. If the file is missing or contains invalid data, the high score defaults to 0.
3. **Saving High Score:** When a new high score is achieved, the `save_high_score()` function updates `main.txt` with the new score.
4. **Game Loop:** The `main()` function allows players to replay the game, asking them if they want to play another round or exit.## Future Improvements:
- **Custom Scoring Range:** Allow players to set their preferred range for `random` scores.
- **Leaderboard:** Implement a leaderboard to display multiple high scores.- **User Profiles:** Allow different users to maintain separate high scores.
## Enjoy playing the Python Guess Game and see if you can beat the high score!