Empowering Students with AI-Powered Assessments & Intelligent Learning
Chapter Exam

Chapter-1 Exception Handling in Python — Online MCQ Test

COMPUTER SCIENCE · Grade 12 · CBSE(NCERT)

Practice Chapter-1 Exception Handling in Python with a free chapter-wise online MCQ test for CBSE(NCERT) Grade 12 COMPUTER SCIENCE. This chapter covers: try - except - else - finally - runtime errors - exception handling. AI-generated questions from basic to board-exam level, with instant results and explanations.

10
Questions
20m
Time Limit
3
Attempts Left
  • 10 random questions from this chapter (mixed difficulty)
  • Questions you've seen before won't repeat until the pool resets
  • You have 20 minutes — exam auto-submits when time is up
  • Maximum 3 attempts per chapter
  • Results and explanations shown immediately after submission
Login to Start This Exam →

New here? Register free — includes 3 free chapter exams.

Chapter-1 Exception Handling in Python — Important Questions & Answers (FAQ)

Frequently asked questions from CBSE(NCERT) Grade 12 COMPUTER SCIENCE — Chapter-1 Exception Handling in Python, with answers and explanations. These are sample questions; the exam has its own separate question set.

What is an exception in Python?
  • A. A type of loop used in programming
  • B. An event that occurs during program execution that disrupts the normal flow of the program ✓
  • C. A function that always returns an error
  • D. A variable that stores error messages
Answer: B. An event that occurs during program execution that disrupts the normal flow of the program
An exception is an error event that disrupts normal program execution, which Python handles using exception handling mechanisms.
Which keyword is used to catch an exception in Python?
  • A. catch
  • B. handle
  • C. except ✓
  • D. error
Answer: C. except
The 'except' keyword is used in Python to catch and handle exceptions that occur in the try block.
What is the purpose of the 'try' block?
  • A. To define a function
  • B. To contain code that might raise an exception ✓
  • C. To repeat code multiple times
  • D. To create a loop structure
Answer: B. To contain code that might raise an exception
The try block contains the code that might potentially raise an exception during execution.
Which of the following is a runtime error in Python?
  • A. Syntax error
  • B. IndentationError
  • C. ZeroDivisionError ✓
  • D. NameError in import statement
Answer: C. ZeroDivisionError
ZeroDivisionError is a runtime error that occurs when attempting to divide a number by zero during program execution.
What happens if an exception is not caught in a try-except block?
  • A. The program continues normally
  • B. The program terminates and displays an error message ✓
  • C. The program ignores the error
  • D. The program automatically fixes the error
Answer: B. The program terminates and displays an error message
If an uncaught exception occurs, the program terminates and Python displays a traceback showing the error details.
What is the difference between 'except Exception:' and 'except ValueError:'?
  • A. They are exactly the same
  • B. Exception catches all exceptions, while ValueError catches only value-related errors ✓
  • C. ValueError is more general than Exception
  • D. Exception is outdated and should not be used
Answer: B. Exception catches all exceptions, while ValueError catches only value-related errors
Exception is a base class that catches all exceptions, while ValueError specifically catches exceptions related to invalid values.
Which exception would be caught by 'except (ValueError, TypeError):'?
  • A. Only ValueError
  • B. Only TypeError
  • C. Either ValueError or TypeError ✓
  • D. None of the above
Answer: C. Either ValueError or TypeError
Using a tuple of exception types allows catching multiple specific exceptions in a single except block.
What happens when an exception occurs in the finally block?
  • A. It is ignored
  • B. It propagates up and can replace the original exception ✓
  • C. It is automatically caught
  • D. The program restarts
Answer: B. It propagates up and can replace the original exception
If an exception occurs in the finally block, it propagates up and can replace or mask the original exception from the try block.
What is the output of this code? try: raise ValueError('Invalid value') except ValueError as e: print(f'Caught: {e}') finally: print('Cleanup')
  • A. Caught: Invalid value\nCleanup ✓
  • B. Cleanup
  • C. Caught: Invalid value
  • D. Invalid value
Answer: A. Caught: Invalid value\nCleanup
The ValueError is raised and caught, printing 'Caught: Invalid value', then finally block executes printing 'Cleanup' on a new line.
Which code will NOT raise an exception when executed?
  • A. x = int('123abc')
  • B. y = {'a': 1}['b']
  • C. z = (1, 2, 3)[1] ✓
  • D. w = 5 / 0
Answer: C. z = (1, 2, 3)[1]
Accessing index 1 of tuple (1,2,3) returns 2 and executes without error, while other options raise ValueError, KeyError, and ZeroDivisionError respectively.

Choose Your Plan & Start Practising

All plans cover every subject and chapter of your registered grade.

Free
₹0
3 exams · 1 year
Start Free →
Active
₹350
12 exams · 1 year
Get Active →
Pro
₹899
Unlimited exams · 1 year
Get Pro →
NEET
₹999
Unlimited exams · 1 year
Get NEET →

Compare all plans in detail →