Skip to main content

Exception Handling In Python — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Exception Handling In Python — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the purpose of exception handling in Python?

Question 2 of 40
★ FPSC ★ PPSC

When is the finally block executed?

Question 3 of 40
★ FPSC ★ PPSC

What is an exception in Python?

Question 4 of 40
★ FPSC ★ PPSC

How many except statements can a try-except block have?

Question 5 of 40
★ FPSC ★ PPSC

What will happen if an exception is raised in a try block and is not handled in any of the except blocks?

Question 6 of 40
★ FPSC ★ PPSC

Which built-in Python function can be used to retrieve the error message associated with an exception?

Question 7 of 40
★ FPSC ★ PPSC

When will the else part of try-except-else be executed?

Question 8 of 40
★ FPSC ★ PPSC

Can one block of except statements handle multiple exception?

Question 9 of 40
★ FPSC ★ PPSC

Which keyword is used to handle exceptions in Python?

Question 10 of 40
★ FPSC ★ PPSC

Which of the following statements is true regarding the order of except clauses?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the assert statement in Python?

Question 12 of 40
★ FPSC ★ PPSC

The following Python code will result in an error if the input value is entered as -5. assert False, 'Spanish'

Question 13 of 40
★ FPSC ★ PPSC

What is the purpose of the except clause in a try block?

Question 14 of 40
★ FPSC ★ PPSC

What is the output of the following code: try: x = 10 / 0 except ZeroDivisionError: print("Error!") finally: print("Finally!")

Question 15 of 40
★ FPSC ★ PPSC

Which of the following is not an exception handling keyword in Python?

Question 16 of 40
★ FPSC ★ PPSC

What is the purpose of the else clause in a try block?

Question 17 of 40
★ FPSC ★ PPSC

What is the purpose of the finally clause in a try block?

Question 18 of 40
★ FPSC ★ PPSC

How can you create a custom exception class in Python?

Question 19 of 40
★ FPSC ★ PPSC

What is the syntax to raise an exception manually in Python?

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def getMonth(m): if m<1 or m>12: raise ValueError("Invalid") print(m) getMonth(6)

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f(x): yield x+1 print("test") yield x+2 g=f(9)

Question 22 of 40
★ FPSC ★ PPSC

What happens when '1' == 1 is executed?

Question 23 of 40
★ FPSC ★ PPSC

Which of the following is not a standard exception in Python?

Question 24 of 40
★ FPSC ★ PPSC

Is the following Python code valid? try: # Do something except: # Do something finally: # Do something

Question 25 of 40
★ FPSC ★ PPSC

What is the purpose of the except clause without specifying an exception type in a try block?

Question 26 of 40
★ FPSC ★ PPSC

Identify the type of error in the following Python codes? Print(“Good Morning”) print(“Good night)

Question 27 of 40
★ FPSC ★ PPSC

Which of the following is not a standard Python exception?

Question 28 of 40
★ FPSC ★ PPSC

What is the purpose of the sys.exc_info() function in Python?

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? g = (i for i in range(5)) type(g)

Question 30 of 40
★ FPSC ★ PPSC

How can you catch and handle multiple exceptions in a single except block in Python?

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def foo(): try: print(1) finally: print(2) foo()

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? int('65.43')

Question 33 of 40
★ FPSC ★ PPSC

An exception is . . . . . . . .

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def f(x): yield x+1 print("test") yield x+2 g=f(10) print(next(g)) print(next(g))

Question 35 of 40
★ FPSC ★ PPSC

Compare the following two Python codes shown below and state the output if the input entered in each case is -6? CODE 1 import math num=int(input("Enter a number of whose factorial you want to find")) print(math.factorial(num)) CODE 2 num=int(input("Enter a number of whose factorial you want to find")) print(math.factorial(num))

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? lst = [1, 2, 3] lst[3]

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? def a(): try: f(x, 4) finally: print('after f') print('after f?') a()

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? x=10 y=8 assert x>y, 'X too small'

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? #generator def f(x): yield x+1 g=f(8) print(next(g))

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code if the input entered is 6? valid = False while not valid: try: n=int(input("Enter a number")) while n%2==0: print("Bye") valid = True except ValueError: print("Invalid")

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →