1. Home
  2. Data Science
  3. Python
  4. What is the output of the following Python code snippet?

Added 25 Nov 2026

What is the output of the following Python code snippet?

try:
1 / 0
except ZeroDivisionError:
print('Cannot divide by zero')
  1. 0
  2. inf
  3. Cannot divide by zero Correct answer
  4. Error

Correct answer

C. Cannot divide by zero

MCQSEXAM

Explanation

Dividing by zero raises ZeroDivisionError, which the except block handles.

Reference

Asked in: Python Interview Exception Handling

https://docs.python.org/3/tutorial/errors.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs