GH avatar 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!

go back Advanced level
Bitecoin 4X

57 out of 60 users completed this Bite.
Will you be Pythonista #58 to crack this Bite?
Resolution time: ~95 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 6.4 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Buy Now Login and get coding
We use Python 3.7