Intermediate
Raise your own error
Define class InvalidScore(ValueError): pass.
Write grade(score). If the score is below 0 or above 100, raise InvalidScore with a message that includes the score. Otherwise return the text "pass" for a score of 40 or more, and "fail" for a score below 40.
What Check tests
grade(75)is passgrade(10)is failgrade(40)is pass (boundary)grade(120)raises InvalidScoregrade(-1)raises a ValueError- The boundaries 0, 39 and 100 are valid
- The message includes the bad score
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.