Class XII Computer Science Chapter 1 MCQs (Mixed) — Exception Handling
Chapter 1 in Class XII Computer Science often introduces errors and exceptions in Python. MCQs here test the exact meaning of try/except/else/finally, when finally runs, what raise does, and which built-in exception appears for common mistakes.
This mixed set gives you exam-style questions with short, clear explanations so you can revise quickly.
MCQs (Mixed Practice)
1) In Python, an exception is
A. always a syntax mistake
B. a runtime event that disrupts normal flow
C. a warning that never stops execution
D. a comment written by the programmer
Correct Answer: B
2) Which block is used to catch/handle exceptions?
A. catch
B. except
C. handle
D. error
Correct Answer: B
3) What does this do?
assert x >= 0
A. forces x to become non-negative
B. raises AssertionError if x >= 0 is false
C. catches all exceptions
D. prints x
Correct Answer: B
Explanation: assert tests a condition and fails fast if it’s false.
4) Which exception occurs when dividing by zero?
A. ValueError
B. TypeError
C. ZeroDivisionError
D. IndexError
Correct Answer: C
5) Which exception occurs when a variable name is not defined?
A. NameError
B. KeyError
C. ImportError
D. IndentationError
Correct Answer: A
Revision Tip: Memorise 5 common ones: NameError, TypeError, ValueError, IndexError, KeyError.
6) finally block runs
A. only when an exception happens
B. only when no exception happens
C. in all cases (almost always)
D. only when assert is used
Correct Answer: C
Explanation: finally is for cleanup actions.
7) What is the purpose of raise?
A. to handle an exception
B. to create a loop
C. to throw an exception intentionally
D. to stop Python from showing errors
Correct Answer: C
8) In a try/except/else structure, the else block runs when
A. exception occurs
B. no exception occurs in try
C. always
D. only when finally is absent
Correct Answer: B
9) What exception is raised by int('12a')?
A. TypeError
B. NameError
C. ValueError
D. ZeroDivisionError
Correct Answer: C
10) If an exception is not handled anywhere, Python will
A. ignore it and continue
B. stop the program and show a traceback
C. fix it automatically
D. convert it to a warning
Correct Answer: B
11) Accessing L[10] when L has only 3 elements raises
A. IndexError
B. KeyError
C. ValueError
D. StopIteration
Correct Answer: A
12) Accessing d['missing'] when key doesn’t exist raises
A. IndexError
B. KeyError
C. NameError
D. ValueError
Correct Answer: B
13) Which is the correct syntax?
A. try: ... catch: ...
B. try: ... except: ...
C. attempt: ... except: ...
D. try: ... handle: ...
Correct Answer: B
14) What happens after an exception is raised inside a try block?
A. remaining statements in try continue
B. control jumps to the matching except (if any)
C. Python silently skips the error
D. program always restarts
Correct Answer: B
15) Which is best practice for catching exceptions?
A. use except: for everything
B. catch the specific exception type you expect
C. never use finally
D. always suppress the error
Correct Answer: B
Explanation: Specific exceptions avoid hiding real bugs.