Friday, April 11, 2014

SOLUTION Exercise 9: Randomness, a guessing game

I apologize for being a day late on the solution / exercise for this week, I hope you'll enjoy it anyway!

Exercise


Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. (Hint: remember to use the user input lessons from the very first exercise)

Extras:



  • Keep the game going until the user types "exit"
  • Keep track of how many guesses the user has taken, and when the game ends, print this out.

  • Sample solution


    Great example of a solution including both extras!

    No comments:

    Post a Comment