0% found this document useful (0 votes)
45 views

Lab Task 14

This document describes an experiment on exception handling in Python. It provides examples of using try-except blocks to catch multiple exceptions like IndexError and ArithmeticError. It also asks to design programs that demonstrate exceptions like EOFError, IndentationError, and IOError by using try-except blocks and describing the expected output.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Lab Task 14

This document describes an experiment on exception handling in Python. It provides examples of using try-except blocks to catch multiple exceptions like IndexError and ArithmeticError. It also asks to design programs that demonstrate exceptions like EOFError, IndentationError, and IOError by using try-except blocks and describing the expected output.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No.

14
Lab 14 – Exception Handling in Python

Exercise:
Q.1
It is possible to catch multiple (different) exceptions that may be raised in a Try block using multiple (or a
series of) except blocks. For example we can write two Except blocks; one for catching an IndexError and the
second is for catching ArthmaticError(by taking two lists consisting of equal no of items ,and perform division
with each pair of list elements). Remember that the IndexError is raised when an element of an array whose
index is out of the range of the array is accessed. An out of range index can be either less than zero or greater
than or equal to the size of the array. The code below demonstrates the use of multiple Except blocks

CODE:

OUTPUT:

Q.2.
Design a python program to demonstrate EOF Error by using Try-Except Block
CODE:

OUTPUT:

.
Q.3
Design a python program to demonstrate IndentationError by using Try-Except Block.
CODE:

OUTPUT:

Q.4
Design a python program to demonstrate IOError by using Try-Except Block.
CODE:

OUTPUT:

You might also like