Simple python code to Earn


SUBMITTED BY: Guest

DATE: Dec. 15, 2013, 6:03 a.m.

FORMAT: Python

SIZE: 662 Bytes

HITS: 725

  1. # exception
  2. # nested try block
  3. # scope of try block: dynamic
  4. # exception propagates towards the try block
  5. #
  6. def g() :
  7. print("five")
  8. print(10/0)
  9. print("six")
  10. def f() :
  11. print("four")
  12. g()
  13. print("seven")
  14. try :
  15. print("one")
  16. f()
  17. print("ten")
  18. print("end of try")
  19. except NameError as e :
  20. print("no such name")
  21. print(e)
  22. except Exception as e :
  23. print(e, type(e))
  24. # can get the stack trace
  25. except : # catch all handler; should be the last
  26. print("something wrong")
  27. finally: # always executed
  28. print("this is final")
  29. print("end of program")

comments powered by Disqus