Skip to content

About

Number guessing game (1–100) in Python, plus a playable 'Hot or Cold' browser version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Number Guessing (Python)

This was one of the first programs I wrote while learning Python. The computer picks a number from 1 to 100, you guess it, and it tells you whether you're too high or too low. It's small, but it covers the basics: loops, input validation, and keeping the logic separate so it can be tested.

I've since added a browser version called Hot or Cold, so you can play without installing anything. It has a heat meter and a number line that shrinks as you close in.

Play in your browser: https://dave-4u.github.io/python-number-guessing/

Hot or Cold, browser version

Quickstart

./run.sh          # play in the terminal (Python 3.8+)
./run.sh test     # run the unit tests

On Windows: python guess.py and python -m unittest discover -s tests -t .

Number Guessing Game
I picked a number from 1 to 100. Try to guess it. (type q to quit)

Your guess: 50
Too high.

Your guess: 25
Too low.

Features

  • Terminal: friendly input validation, q to quit, play-again prompt, and your best score for the session
  • Browser (docs/index.html):
    • heat meter (freezing → on fire)
    • a 1–100 number line that greys out the numbers it can't be
    • guess history chips, a gentle shake for invalid or repeated guesses, and confetti when you win
    • best score saved in your browser, and keyboard play (Enter, N for a new number)
  • Logic is split into check_guess() and parse_guess(), with tests in tests/

Tech stack

Python 3 (standard library only) and unittest. The web version is a single HTML file with vanilla JS.

Roadmap

  • Difficulty levels (1–50, 1–1000)
  • A "you play the computer" mode where it guesses your number with binary search

License

MIT © Adegboro David Oluwadamilare

About

Number guessing game (1–100) in Python, plus a playable 'Hot or Cold' browser version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages