avatar Bite 10. Practice exceptions

In this Bite you'll learn to catch and raise Python exceptions.

Write a simple division function meeting the following requirements:

1. When the denominator is zero, catch the corresponding exception and return zero.

2. When the numerator or denominator have an invalid type reraise the corresponding exception.

3. If the result of the division is negative raise a ValueError.

Check the tests if you have questions about what your code needs to pass. Have fun!

Login and get coding
go back Intermediate level
Bitecoin 3X

352 out of 359 users completed this Bite.
Will you be Pythonista #353 to crack this Bite?
Resolution time: ~27 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.
We use Python 3.8