arrow
arrow
arrow
Which of the following options is true in Python?
Question

Which of the following options is true in Python?

A.

Execution/Runtime errors can be handled using try...except

B.

No errors can be handled using try...except

C.

Logical errors can be handled using try...except

D.

Syntax errors can be handled using try...except

Correct option is A


In Python, execution/runtime errors (also called exceptions) can be handled using the try...except block. This mechanism allows you to catch errors that occur during the execution of the program and handle them gracefully, without terminating the program unexpectedly.
Important Key Points:
1. Try-Except Block: The try block contains code that might raise an exception, while the except block contains code to handle that exception.
2. Handling Runtime Errors: Common runtime errors such as ZeroDivisionError, FileNotFoundError, etc., can be caught and handled using this approach.
3. Graceful Recovery: The purpose of try...except is to allow the program to continue running even when an error occurs.
Knowledge Booster:
· Option (b): This is incorrect because execution/runtime errors (exceptions) can indeed be handled using try...except. The statement that "no errors can be handled" is false.
· Option (c): Logical errors (like incorrect program logic) cannot be handled using try...except. These errors do not raise exceptions, and they are often caught through debugging and testing.
· Option (d): Syntax errors occur during the parsing phase before the program runs and cannot be handled using try...except. These errors prevent the code from executing and need to be fixed before running the program.

Free Tests

Free
Must Attempt

UPTET Paper 1: PYP Held on 23rd Jan 2022 (Shift 1)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Maths & Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘EMRS PGT’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow