Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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":

print

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

print

Example 1:

image text in transcribed

Example 2:

image text in transcribed

Welcome to the Smart Computer Guessing Game Check Number: 31 Try(s): 4 Number guessed: 31

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

Students also viewed these Databases questions