Write a Python program that demonstrates how various exceptions are caught with except Exception, exception
What will be an ideal response?
```
# Processing generic exceptions with base class Exception.
import random
# list of exceptions to raise
exceptions = [ ArithmeticError, AssertionError, AttributeError,
Exception, IndexError, KeyError, ValueError ]
for exceptionType in exceptions:
# raise each exception, with a random integer argument
try:
raise exceptionType, random.randrange( 1, 100 )
# catch exception by specifying base-class Exception type
except Exception, exceptionInstance:
print "Exception %s caught: %s" % \
( exceptionInstance.__class__, exceptionInstance )
```
Exception exceptions.ArithmeticError caught: 11
Exception exceptions.AssertionError caught: 37
Exception exceptions.AttributeError caught: 25
Exception exceptions.Exception caught: 15
Exception exceptions.IndexError caught: 88
Exception exceptions.KeyError caught: 99
Exception exceptions.ValueError caught: 10
You might also like to view...
What is the difference between a high fidelity and a low fidelity prototype?
What will be an ideal response?
Create a directory called linux in your home directory. What command line did you use? What command would you use to create the directories called memos and personal in your home directory?
What will be an ideal response?
________ allow you to move the view within the window to display different parts of the file or other content
A) Scroll boxes B) Title bars C) Navigation panes D) Scroll bars
Using a fluid grid means that you can see the page as it will appear on different devices as you create it.
Answer the following statement true (T) or false (F)