Guest User

Untitled

a guest
Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. from random import randint
  2. for i in range(100):
  3. print(1 / randint(0, 10))
  4.  
  5. 0.1111111111111111
  6. 0.1
  7. 0.25
  8. 0.3333333333333333
  9. 0.1
  10. 0.2
  11. 0.16666666666666666
  12. 1.0
  13. 0.1
  14. 0.5
  15. 1.0
  16.  
  17. ---------------------------------------------------------------------------
  18. ZeroDivisionError Traceback (most recent call last)
  19. <ipython-input-11-bfba3ff98af3> in <module>()
  20. 1 from random import randint
  21. 2 for i in range(100):
  22. ----> 3 print(1 / randint(0, 10))
  23.  
  24. ZeroDivisionError: division by zero
  25.  
  26. class MoreThanFiveZeroDiv(ZeroDivisionError):
  27. pass
  28.  
  29. from random import randint
  30. for i in range(100):
  31. try:
  32. print(1 / randint(0, 10))
  33. except MoreThanFiveZeroDiv
Add Comment
Please, Sign In to add comment