Question:

State whether the following statement is True or False:

In Python, Logical errors can be handled using try…except…finally statement.

Show Hint

try...except...finally catches only exceptions raised while the program runs. A logical error raises no exception, so it cannot be handled this way.
Updated On: Oct 20, 2026
Show Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Know the three kinds of errors:
A Python program can fail in three ways: syntax error, runtime error (exception) and logical error.
A syntax error breaks the grammar rules of Python, so the program does not even start.
A runtime error happens while the program runs, for example dividing by zero.
A logical error gives a wrong result, but the program runs without any complaint.

Step 2: See what try...except...finally does:
The try block holds code that may raise an exception.
The except block catches that exception when Python raises it.
The finally block runs at the end, whether an exception came or not.
So this statement works only when Python itself raises an exception object.

Step 3: Test a logical error against this tool:
Suppose a program finds the average of three marks but divides the total by 2 instead of 3.
Python finds nothing wrong, so it raises no exception.
The except block never gets a chance to run, and the wrong average is printed.
A logical error is found only by testing, tracing the code and fixing the formula by hand.

Step 4: Decide the statement:
try...except...finally can handle runtime errors (exceptions) such as ZeroDivisionError and ValueError.
It cannot handle logical errors, because no exception is raised for them.
So the given statement is not correct.

Final Answer:
The statement is False, because logical errors do not raise exceptions, so try...except...finally cannot handle them.
Was this answer helpful?
0
0