Puzzle 3 – Linear Search Algorithm

Introduction

A linear search algorithm is much easier to code because you don't have to work out whether to say higher or lower each time.

You can probably look back at your binary search program and figure out how to do this yourself:

  1. start with the titles as always
  2. create the random number – don't forget to import random at the top
  3. get the user to make a guess – use input and don't forget to use int to turn the input in to a number
  4. keep dong this until they get the number right
  5. add in a way to keep track of guesses

See if you can figure out how to do this by yourself before you look at the steps.