Skip to content

senator032/Number-Guessing-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Number Guessing Game

A simple command-line Python game where the computer chooses a random number and the player guesses it using higher-or-lower hints.

Features

  • Three difficulty levels:
    • Easy: 1 to 100
    • Medium: 1 to 1,000
    • Hard: 1 to 100,000
  • Random number selection for every game.
  • Higher and lower hints after each wrong guess.
  • Attempt counter that shows how many guesses were needed.
  • Basic validation for invalid difficulty choices and out-of-range guesses.

Requirements

  • Python 3
  • No third-party packages

How to Run

Open a terminal in this project folder and run:

python main.py

On Windows, you can also use:

py main.py

Example

Welcome to the Number Guessing Game!

Choose difficulty level
1.Easy(1 - 100)
2.Medium(1 - 1000)
3.Hard(1 - 100000)

Enter difficulty: 1

You have chosen easy level

Guess the number(1 - 100):

Enter your choice: 50
Guess higher!
Enter your choice: 75
Guess lower!
Enter your choice: 63
You guessed it right in 3 attempts!

The hidden number is random, so each playthrough is different.

Project Structure

Number Guessing Game/
|-- main.py    # Main game script
`-- README.md  # Project documentation

Current Limitations

  • The game expects numeric input. Entering text will stop the program with an error.
  • Decimal inputs are converted to whole numbers.
  • Out-of-range guesses do not increase the attempt count.
  • The game ends after one successful round.

Possible Improvements

  • Add stronger input validation for non-numeric values.
  • Ask the player if they want to play again.
  • Add a maximum attempt limit.
  • Save the best score for each difficulty level.
  • Improve the display formatting for menus and messages.

License

This project is available for learning, experimentation, and personal use.

About

A simple command-line Python number guessing game where the player selects a difficulty level, guesses a randomly chosen number, and uses higher-or-lower hints to find the answer in as few attempts as possible.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages