top of page

The Guessing Game

  • Writer: VC Healy
    VC Healy
  • Aug 5, 2020
  • 1 min read

There are many variations of the guessing game, where a random integer has to be guessed in 5 guesses or less.

After successfully completing my first Advanced bite on @Pybites. I noticed their take on the game in the form of another Advanced bite. So I thought I would have a go at it. Just to make it more of a challenge I didn't open the bite to see the template code to start with or the pytests that would give a pass of the bite.


No, I went for it with just the brief. Handles exceptions for an empty entry, a non-numeric character and to note if the guess was previously entered. This is above the usual lower, higher, correct or too many guesses.



Generate the random number is a separate function to the class. With variable that can be altered. ( I renamed the variable to that used in the PyBite before I took the screenshot)


The class would handle everything else. I had a lot more detail in my code than required for the test. Counting guess attempts, and deducting attempts if there was an erroneous guess.

The messages f' strings were a lot more detailed than required. So I dumbed it down a bit.


Again the screenshot is of a working hybrid of what I designed myself and some reductions of content to ensure that the pytests would pass. The developed code will slot into the PyBite code, with a little work on the class details.



 
 
 

Comments


© 2020 by Vincent Healy. Proudly created with Wix.com

bottom of page