Question: Write a python program that uses an indefinite while loop to play a number guessing game with the user. The program will need to generate
Write a python program that uses an indefinite while loop to play a number guessing game with the user. The program will need to generate a random integer between O and 1000 to be guessed by the user. Recall that generating random numbers was discussed in Chapter 4. User a counter variable to keep track of the number of guesses. The program will enter into an infinite loop until the correct number is guessed or until the user reached some maximum number of allowed guesses. Inside the body of the loop, begin by prompting the user to guess an integer. Each time the user guesses an incorrect number, the program should respond by giving the user a hint of too high or too low. Once the correct number is guessed, use a brealk statement to exit the loop. Also break out of the loop if they reach the max allowed guesses After the loop finishes, display a success / failure message along with the number of guesses Don't Forget: - Use comments for documentation purposes. . Use meaningful, descriptive variable and function names . Use exception handling when converting user input to int or float
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
