Prince-linux / python-learning

for learning Python
MIT License
1 stars 0 forks source link

Create number guessing game #22

Open lcabrini opened 9 years ago

lcabrini commented 9 years ago

Create an object-oriented version of a number guessing game. It works as follows:

  1. The game "thinks of" a number between 1 and 100
  2. The user is asked to guess the number.
  3. If the user's guess is greater than the secret number the game prints "too high"
  4. if the user's guess is lower than the secret number the game prints "too low"
  5. As long as the user has not guessed the correct number, they are asked to make another guess
  6. When the user guesses the correct number, the game prints "You did it!" and then tells the user the number of guesses they needed before they got the number.
  7. Once the game is over the user is asked if they want to play again. If they say "yes" the game starts over with a new secret number. If they say no, the program exits

They game should also have a cheat mode which is activated by passing --cheat in as a command-line argument. That is:

$ ./guess-the-number.py --cheat

Should activate cheat mode. This will print out the secret number before the user starts guessing. It may be useful to use this mode while developing the game.

Place the game in a folder called guess-the-number.