Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question 3 what will the following code print? try: 5/0 except zerodivi…

Question

question 3
what will the following code print?
try:
5/0
except zerodivisionerror:
print(\cannot divide by zero!\)
print(\program is still running\)
0
zerodivisionerror: division by zero
program is still running.
cannot divide by zero! program is still running.

Explanation:

Step1: Analyze the code

The code tries to perform 5/0 which raises a ZeroDivisionError. The except block catches this error and prints "Cannot divide by zero!".

Step2: Check the remaining code

After the except block, the code print("Program is still running") is outside the except block but in the same indentation level as the except block. So it will execute.

Answer:

Cannot divide by zero! Program is still running.