Bite 42. Number Guessing Game Class

In this Bite you implement a Game class to perform a number guessing game. It lets a user do a max of 5 guesses of a secret number between 1 and 20 randomly defined by the class.

Note you have to account for invalid inputs: raise a ValueError if a user hits Enter (nothing entered), a non-numeric value, a number that is not in the 1-20 range, or guesses the same number again. See the template code below ... (Advanced Bite, not giving away too much!)

The tests run through a lose scenario as well. Note they mock out the input builtin to test this. And you will be tested on stdout too so use print statements in addition to return values. Here is how the program would work from the command line.

Good luck, have fun and keep calm and code in Python!

Will you be Pythonista #28 to crack this Bite?
It takes an average of ~120 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 7.33 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Login and get coding
We use Python 3.7