Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python. use only the for and while loops Question 7: Implement a number guessing game. The program should randomly choose ain integer between 1
In python. use only the for and while loops
Question 7: Implement a number guessing game. The program should randomly choose ain integer between 1 and 100 (inclusive), and have the user try to guess that number. Implementations guidelines: 1. The user can guess at most 5 times 2. Before each guess the program announces: * An updated guessing-range, taking in to account previous guesses and responses The number of guesses that the user has left. . 3. If the user guessed correctly, the program should announce that, and also tell how many guesses the user used. 4. If the user guessed wrong, and there are still guesses left, the program should tell the user if the number (it chose) is bigger or smaller than the number that the user guessed. 5. If the user didn't guess the number in all of the 5 tries, the program should reveal the number it chose 6. Follow the execution examples below for the exact format. Execution example 1: I thought of a number between 1 and 100! Try to guess it. Range: [1, 100], Number of guesses left: 5 Your guess: 15 Wrong! My number is bigger. Range: [16,100], Number of guesses left: 4 Your guess: 34 Wrong! My number is smaller. Range: [16, 33], Number of guesses left: 3 Your guess: 23 Congrats! You guessed my number in 3 guesses Execution example 2: I thought of a number between 1 and 100! Try to guess it. Range: [1, 1001, Number of guesses left: 5 Your guess: 15 Wrong! My number is bigger. Range: [16,100], Number of guesses left: 4 Your guess: 50 Wrong! My number is smallerStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started