Question:

Which of the following are used in python exception handling?
Options:
A) try
B) except
C) finally
D) seek
Choose the correct answer from the options given below:

Updated On: May 28, 2025
  • (A), (B), and (D) only
  • (A), (B), and (C) only
  • (A), (B), (C), and (D)
  • (B), (C), and (D) only
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Approach Solution - 1

Python exception handling is a mechanism to handle runtime errors, allowing the program to continue execution. The following keywords are used in Python exception handling:

  1. try: This block is used to surround the code that might throw an exception.
  2. except: This keyword is used to catch and handle exceptions that are raised in the try block.
  3. finally: This block is executed after the try block has finished, regardless of whether an exception was raised or not. It is often used for cleanup activities.

The option seek is not used in Python exception handling. It is a file operation method used to move the file pointer within the file.

Based on the explanation, the correct answer is: (A), (B), and (C) only

Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

Python uses try, except, and finally for structured exception handling. 
The seek() method is unrelated, as it is used for file operations.

Exception handling in Python is used to manage runtime errors gracefully. 

  • try: Encloses code that might raise an exception.
  • except: Catches and handles exceptions.
  • finally: Executes cleanup code, regardless of whether an exception occurred.
OptionPurposeRelevance to Exception Handling
A) tryDefines a block where exceptions may occur.Core part of exception handling.
B) exceptCatches and processes exceptions.Essential for handling errors.
C) finallyEnsures execution of code after try/except.Used for cleanup (e.g., closing files).
D) seekMoves the file pointer in file operations.Not related to exceptions; used in file handling.
  • The correct combination is (A), (B), and (C).
Was this answer helpful?
0
0