Menu

[Solved]-Python Part 1 Predefined Exception Class Listed Describe Reasons Exception Triggered Excep Q37169381

python:

part 1:

For each of the predefined exception class listed below,describe for what reasons the

exception is triggered.

Exception Description

AssertionError          Raisedwhen the condition is false.

ZeroDivisionError       Raisedwhen a number is modulo zero or is divided by zero.

NameError          Raisedwhen a local or global name is not found.

MemoryError      Raisedwhen an operation runs out of memory.

ValueError         Raisedwhen an operation or function receives an argument that has

the right type but an inappropriate value.

IndexError Raised whenever attempting to accessan index that is outside the

bounds of a list.

KeyError Raised when the key is not found inthe dictionary.

ImportError Raised when an import statementfails to find the module definition

or when a from… import fails to find a name that is to beimported.

SyntaxError Raised when there is an error inthe syntax.

FileNotFoundError Raised when a file ordirectory is requested but it doesn’t exist.

Part 2

Write a Python class called MyList that has one attribute whichis a list (pList). Include

the following methods to do the listed functions.

• __init__: to initialize pList

• __add__: to join two lists

• __mul__: to update pList with n copies of itself

• __repr__: to print the content of the list, each element on aseparate line

Expert Answer


Answer to python: part 1: For each of the predefined exception class listed below, describe for what reasons the exception is trig… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *