Question
Smart Guessing Game Programming Language: Python 3 For this program, you will need to use the given code and make add the following requirements: -The
Smart Guessing Game
Programming Language: Python 3
For this program, you will need to use the given code and make add the following requirements:
-The program before was asking the user to guess the number, but now the goal is to create a program where the computer will use the binary search algorithm to autonomously do the guessing all at once.
-Add a new variable called check. This check variable will be used as the number the smart program will be aiming for.
-Add a new variable called try. This variable will print out the amount of tries the autonomous program did to get to the correct answer in the range from 1 to 99.
Please see output examples given below.
import random
x = random.randint(1, 99)
guess = int(raw_input("Enter an integer from 1 to 99: "))
while x != "guess":
if guess
print "guess is low"
guess = int(raw_input("Enter an integer from 1 to 99: "))
elif guess > x:
print "guess is high"
guess = int(raw_input("Enter an integer from 1 to 99: "))
else:
print "AWESOME!"
break
Example 1:
Example 2:
Welcome to the Smart Computer Guessing Game Check Number: 31 Try(s): 4 Number guessed: 31Step 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