Question: In python: Write a program to accept as input a 'magic' integer. Then allow the user to guess the magic number until they have guessed

In python: Write a program to accept as input a 'magic' integer. Then allow the user to guess the magic number until they have guessed correctly. When the guess is incorrect, provide a clue that the guess is either too low or too high and allow the user to guess again. Print the number of guesses the user needed before guessing the number correctly.

If the inout is:

5

8

7

9

2

1

5

The output should be:

Enter your guess 8

No, heres a clue. Your guess is too high. Next guess 7

No, heres a clue. Your guess is too high. Next guess 9

No, heres a clue. Your guess is too high. Next guess 2

No, heres a clue. Your guess is too high. Next guess 1

No, heres a clue. Your guess is too high. Next guess 5

Yes, the magic number is 5. It took you 6 try/tries to guess

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!