Question: Write a Python program that generates a random number between 1 and 1 0 0 . The program prompts the user to guess the number.

Write a Python program that generates a random number between 1 and 100. The program
prompts the user to guess the number. If the guess is higher or lower than the random number,
the program provides feedback ('Too high, try again' or 'Too low, try again'). If the guess is
correct, the program congratulates the user and displays the number of guesses made. The
program allows the user to quit the game at any time by entering 0(the digit zero) as a guess.
Example run:
Gues the number (enter 0 to quit): 77
Too high, try again.
Gues the number (enter 0 to quit): 37
Too high, try again.
Gues the number (enter 0 to quit): 23
Too high, try again.
Gues the number (enter 0 to quit): 12
Too low, try again.
Gues the number (enter 0 to quit): 18
Too low, try again.
Gues the number (enter 0 to quit): 21
Congratulations! You guessed the number 21 correctly in 6 guesses.

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 Accounting Questions!