Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Guess the Number Game

Introduction

This project contains two versions of the Guess the Number game:

  • main.py: The basic version, implementing the core guessing functionality.
  • main_stretch.py: The stretch version, supporting multiple rounds and personal best tracking.

Game Rules

  • The program randomly selects an integer between 1 and 100.
  • The player enters a guess, and the program responds with "Too high!", "Too low!", or "Correct!".
  • When the correct number is guessed, the program displays the total number of attempts.

Stretch Version Features

  • After each round, the player is asked whether to play again.
  • The program keeps track of and displays the best (fewest) number of guesses across rounds.
  • If a new personal best is achieved, a special message is shown.

How to Run

  1. Make sure Python 3 is installed.
  2. Open a terminal and navigate to the project directory.
  3. To run the basic version:
    python3 main.py
  4. To run the stretch version:
    python3 main_stretch.py

Sample Interaction

I'm thinking of a number between 1 and 100.
Take a guess: 50
Too low!
Take a guess: 75
Too high!
Take a guess: 63
Correct! You guessed the number in 3 tries.

Stretch Version Example

I'm thinking of a number between 1 and 100.
Take a guess: 42
Too high!
Take a guess: 21
Too low!
Take a guess: 33
Correct! You guessed the number in 3 tries.
New personal best: 3 guesses!
Play again? (y/n): y
...
Thank you for playing!

Notes

  • If a non-integer is entered, the program will prompt for a valid input.
  • The stretch version supports multiple rounds and best score tracking.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages