Bonus Exercise
Guess the Number
Instructions
Build a basic "guess the number" game. The player will keep guessing numbers until they guess correctly.
Specification
Hard-code a number in a variable for the player to guess (keep it between 0 and 10).
The player should be asked to guess the number.
If the player's guess is correct, the game should stop and the player should see a congratulatory message.
If the player's guess is not correct, the game should continue and the player should be asked to guess the number again.
Extensions
Each time the player guesses incorrectly, give them feedback: "Wrong, guess higher!" or "Wrong, guess lower!"
Rather than hard-coding a number to the computer, see if you can generate a random number between 0 and 10.
Let the player choose the maximum value for the computer (so they can play a long game with a random value between 0 and 10000, for example).
Last updated
Was this helpful?