Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- for i in range(100):
- print(1 / randint(0, 10))
- 0.1111111111111111
- 0.1
- 0.25
- 0.3333333333333333
- 0.1
- 0.2
- 0.16666666666666666
- 1.0
- 0.1
- 0.5
- 1.0
- ---------------------------------------------------------------------------
- ZeroDivisionError Traceback (most recent call last)
- <ipython-input-11-bfba3ff98af3> in <module>()
- 1 from random import randint
- 2 for i in range(100):
- ----> 3 print(1 / randint(0, 10))
- ZeroDivisionError: division by zero
- class MoreThanFiveZeroDiv(ZeroDivisionError):
- pass
- from random import randint
- for i in range(100):
- try:
- print(1 / randint(0, 10))
- except MoreThanFiveZeroDiv
Add Comment
Please, Sign In to add comment