Question: Using Python with while loops Write a Python program that 1) generates a random number n (an integer) between 0 and 100, inclusive, and 2)

Using Python with "while loops"

Write a Python program that 1) generates a random number n (an integer) between 0 and 100, inclusive, and 2) iteratively prompts the user to "guess" the number (the guess should be in the interval [0,100]) until they guess the correct number (n). After each guess, if the number is correctly guessed, print to the console "You found the number in M guesses!" (replace M with the actual number of guesses made). If the guess is greater than n, print to the console "Your guess is too high", and if the guess is less than n, print to the console "Your guess is too low". In the latter two cases you should prompt the user to enter an additional guess. Repeat until the number (n) is correctly guessed.

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!