Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python. Think of a number between 0 and 100. How could be make a computer guess the number? The simplest method is to just

image text in transcribedimage text in transcribedIn Python.

Think of a number between 0 and 100. How could be make a computer guess the number? The simplest method is to just guess every value. This is a poor method. In real life, you would never use this solution. If someone had a number you were trying to guess, you would gain information with every failed guess. n our guessing game, when the guess is incorrect the person with the secret number will say "higher" or "lower". This gives the other player information about where to guess next. (You can also play with hotter or "colder" but that algorithm is a bit harder) Here is a basic layout of the higher/lower algorithm. Implement it in Python. Set three values low-0, high-101, guess-50 While you have not guess correctly o Ask the user if it is correct, higher, or lower o If the secret number is lower than the guess set high-guess and your next guess is (guess-low)//2+low oIf the secret number is higher than the guess set low-guess and your next guess is (high-guess)//2+guess If the input was not valid, say "I did not understand:" and make the same guess again. Your output should match the below example Hello Pick a secret number between 0 and 100. Is your secret number 50 Enter yes/higher/lower: lower Next is 25 is your secret number 25 Enter yes/higher/lower: higher Next is 37

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

Describe the five steps in the performance appraisal process.

Answered: 1 week ago