100% found this document useful (1 vote)
260 views3 pages

12 Unit Test 2 - Exception Handling

Uploaded by

naga06557
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
100% found this document useful (1 vote)
260 views3 pages

12 Unit Test 2 - Exception Handling

Uploaded by

naga06557
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

(Creating the Community of Excellence)

Batch 1I-Unit Test-1


Computer Science(Exception Handling in Python)

Time Allowed:1.30 hr Maximum Marks:40


General Instructions:
1.The Question Paper contains four sections.
2. Section A has 7 questions. (7*2=14)
3. Section B has 3 questions. (3*3=9)
4. Section C has 3 questions. (3*4=12)
5. Section D has 1 question.(1*5=5)

Section A

1.“Every syntax error is an exception but every exception cannot be a syntax error.”
Justify the statement.
2.When are the following built-in exceptions raised? Give examples to support your
answers.
ImportError
IOError
NameError
d) ZeroDivisionError
3. What is the use of a raise statement?
4. Define the following: a) Exception Handling b) Throwing an exception c) Catching
an exception
5. Explain catching exceptions using try and except block.
6. Explain Finally clause?
7. Write any program for Exception handling?
Section B

1.Find and write the output of the following python code:


X=”abcdef”
I=”a”
While I in x:
Print(I,end=” ”)

A.Given the lists L=[1,3,6,82,5,7,11,92], write the output.


2.Predict the output of the following code snippet?
A=[1,2,3,4,5]
Print (a[3:0:-1])
3.Write the output:
Y=str(123)
X=”hello”*3
Print(x,y)
X=”hello”+”world”
Y=len(x)
Print(y,x)
Section c

1. Write the output of the following code:

2. Write the output of the following code:

3.Write the output of the following code:


Section D
Assertion and Reasoning:

1.Assertion (A): Exception handling in Python allows for graceful recovery from
errors and prevents program crashes.
Reason (R): When an error occurs during program execution, Python's exception
handling mechanism allows the program to gracefully handle the error and take
corrective action.

a) Both A and R are correct, and R is the correct explanation of A.

b) Both A and R are correct, but R is not the correct explanation of A.

c)A is correct, but R is not correct.

d)A is not correct, but R is correct.

You might also like