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

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

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

Ask for Help