Guess the Number: Binary Search

guess-the-number-quizBefore attempting this challenge, make sure you have completed our previous Guess the Number challenge first where the player plays against the computer.

In this version, the player will be asked to enter a number between 1 and 100. The computer will then use a binary search algorithm to try to guess the correct number keeping the number of guesses to a minimum.

The binary search is a very effective algorithm to search through a large list that is already sorted, in our case the list of numbers from 1 to 100. It is based on the following flowchart:
binary-search-algorithm

Complete the Code


Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges Tagged with:

Our Latest Book