Skip to main content

A simple number guessing game with difficulty levels

Project description

🎯 Number Guessing Game

A simple Python-based CLI game where the computer randomly selects a number, and the player tries to guess it within limited attempts.
Difficulty levels (easy, medium, hard) change the range of numbers. The game also logs results to a CSV file.


🚀 Features

  • Choose difficulty:
    • Easy → number between 1–20
    • Medium → number between 1–50
    • Hard → number between 1–100
  • Limited attempts (default: 10).
  • Validates user input.
  • Keeps track of wins/losses.
  • Logs results to game_log.csv.

Project Setup and Usage Guide

This guide walks you through setting up your development environment, installing dependencies, and running tests.


1. Create a virtual environment

Run this command in your project directory to create an isolated Python environment:

python3 -m venv env

2. Activate the virtual environment

Activate the environment so your shell uses the isolated Python and packages:

On macOS/Linux: source env/bin/activate

On Windows (Command Prompt): env\Scripts\activate

3. Upgrade pip (recommended)

Make sure you have the latest pip version inside the environment:

pip install --upgrade pip

4. Install project dependencies

If you already have a requirements.txt file, install all required packages:

pip install -r requirements.txt

If you don’t have one yet, install your needed packages manually, for example:

pip install pytest sphinx twine

and then create the requirements.txt file by running:

pip freeze > requirements.txt

5. Run tests or your project

To run tests with pytest:

pytest Or run whatever commands your project uses.

6. Deactivate the virtual environment

When you’re done working, exit the virtual environment:

deactivate

Notes

Always activate your virtual environment before running your project or installing packages.

Keep your requirements.txt updated whenever you add or upgrade packages.

Use version control (like Git) to track changes in your project and dependencies.


🖥️ How to Run

  1. Clone this repository:
    git clone https://github.com/your-username/number-guessing-game.git
    cd number-guessing-game
    

🎮 Example Gameplay

Enter your name: Alice Choose difficulty (easy / medium / hard): easy 🎯 Welcome to Number Guessing Game, Alice! You have only 10 attempts to guess the number between 1 and 20.

Enter your guess 1-20: 10 Too low! Attempts left: 9

Enter your guess 1-20: 15 Too high! Attempts left: 8

Enter your guess 1-20: 13 🎉 You guessed it in 3 attempts.

✅ Logged: Alice, easy, 3, 13, Win

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guess_it_right-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

guess_it_right-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file guess_it_right-0.1.0.tar.gz.

File metadata

  • Download URL: guess_it_right-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for guess_it_right-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c7a407577f540529323429efa838e06a4858166593285b6573c6b938cd92392
MD5 c50fc31f0075f315ac6003de274c5b44
BLAKE2b-256 ec4302522fa4c74fdeaaf28ffcbf27da80b06bf21fb1bb0b96a29302d3ad5612

See more details on using hashes here.

File details

Details for the file guess_it_right-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: guess_it_right-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for guess_it_right-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8848d3d2dafdd560d32fbda88c72c25e2c1522a3ea8918bc02be64b3a309368e
MD5 dfad9303b747a229707f83cd6b5c99ba
BLAKE2b-256 b644aab1a9ee6e358c9b7e17174fcfbda3c031f897ff868b0f29c45c51ce6d5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page