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

Login and get coding
go back Intermediate level
Bitecoin 3X

Will you be the 154th person to crack this Bite?
Resolution time: ~31 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.17 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help