Bite 82. Define a Score Enum and customize it adding methods

Starting Python 3.4 there is support for enumerations (not to confuse with the enumerate builtin). You can define a class that inherits from Enum.

In this Bite we have some constants that are related: the scores we provide for our Bites depending the level and if cheated. As these variables relate they are an ideal candidate to be refactored into an Enum. But that would not be much of a Bite, right? So we added two requirements:

  1. Add a __str__ method so each member would print like this: BEGINNER => 👍👍, where BEGINNER is the level and the number of thumbs ups the amount of points.
  2. Write a classmethod called average that returns an average of the scores in the Enum.

    See the TESTS tab for more info. You might want to read the Enum docs to see how you can pull this off. We hope it clicks and you find joy coding this one, and of course that you earn your full 👍👍👍 for this INTERMEDIATE Bite. Good luck and have fun!

19 out of 20 users completed this Bite.
Will you be Pythonista #20 to crack this Bite?
Average Bite difficulty 1-10 rating: 3.0
» You can do it! 😌

Github login button
We use Python 3.7