What number am I thinking of?
A simple guessing game for young children asks the child to guess the number the computer has chosen at random. The child keeps guessing until they guess correctly.
Write a program that generate a random number and asks the user to guess the number, outputting whether the guess is correct, too high or too low. The program should also output the number of guesses taken once the number has been guessed correctly.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
What is the lowest number I can choose? :1
What is the highest number I can choose? :10
OK, let’s play. How many guesses will you take?
Enter the number I’m thinking of: 5
Your guess is too low.
Enter the number I’m thinking of: 7
You’ve got it, I chose 7. It took you 2 guesses.
Use these resources as a reference to help you meet the success criteria.
Run your program several times to check that your program has met the success criteria.
Check that you have: