Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

In a make task you use the skills you have learned to create a program from scratch. There is no starter code: you begin with an empty editor.

You are going to write a guessing game in which the computer thinks of a number and the user has to find it.

Your task

Write a program that:

Some details, so that your game can be checked automatically:

The output

The opening line, then for every wrong guess the question followed by one message, then the question for the right guess, and finally the two lines at the end:

I am thinking of a number between 1 and 100.
What is your guess?
Your guess is too low
What is your guess?
Well done!
Number of guesses: 2

Example

These examples show what happens when the number is 42 in the first run and 60 in the second. Your program will think of different numbers when you run it yourself.

Input:

50
25
37
43
40
42

Output:

I am thinking of a number between 1 and 100.
What is your guess?
Your guess is too high
What is your guess?
Your guess is too low
What is your guess?
Your guess is too low
What is your guess?
Your guess is too high
What is your guess?
Your guess is too low
What is your guess?
Well done!
Number of guesses: 6

Input:

60

Output:

I am thinking of a number between 1 and 100.
What is your guess?
Well done!
Number of guesses: 1

The checks fix the random seed before your program runs, so they know the number in advance and can type in guesses that eventually hit it. That only works if your program calls random.randint(1, 100) once, before the first guess. Any other call that picks from the same numbers, random.randrange(1, 101) for example, picks the same number and is fine too.

Ask each question with its own print, and read the answer with a bare input() on the next line, rather than passing the question to input(...). The questions are part of the output that is checked here, so their spelling, capital letters and punctuation count.

Help! My code doesn't work!

Make sure that you check for the following things:

  • import random is the first line of the program.
  • random.randint(1, 100) includes both 1 and 100.
  • The loop keeps going for as long as the guess is not the number (!=), and the guess has a value before the loop starts that can never be the number.
  • The question and the input() are both inside the loop.
  • Every guess is wrapped in int(), or it is text and never equal to the number.
  • The guess counter starts at 0 before the loop and goes up by 1 inside it.
  • Well done! and the number of guesses are printed once, after the loop.