ZeroDivisionError
exception.10
and 0
, the program will raise the following exception:FileNotFoundError
)ZeroDivisionError
)ImportError
)try
, except
, else
, and finally
. Let’s explore each one in detail.try
and except
try
block contains the code that may raise an exception. The except
block contains the code to handle the exception if one occurs.10
and 0
, the ZeroDivisionError
will be caught, and the message “Cannot divide by zero” will be printed. else
Blockelse
block contains the code that runs when no exceptions occur. It is optional and is typically used when you want to execute certain actions only when the code in the try
block is error-free.else
for Successful Division10
and 5
), the else
block will execute and print the result.
Click Here to Know more our program!