016. Exception Handling in Python - Web (1)
016. Exception Handling in Python - Web (1)
When we input
valid data, program
will execute
successfully
If denominator is
entered as 0, then
program will crash
with runtime error
“ZeroDivisionError”
Prepared by - Vinod Kumar Verma, PGT(CS)
, Sachin Bhardwaj PGT(CS)
Example – 2 (Handling Divide by Zero)
When we input
valid data, program
will execute
successfully
If denominator is entered
as 0, then program will
not abnormally terminate
and error is handled
gracefully
Prepared by - Vinod Kumar Verma, PGT(CS)
, Sachin Bhardwaj PGT(CS)
Example – 2 (Handling Divide by Zero)
Name of specific
exception is given
As only ZeroDivisionError exception is handle here, if any other runtime error occurs like if
we input string data in place ofPrepared
int data, thenKumar
by - Vinod program will crash with ValueError Exception
Verma, PGT(CS)
, Sachin Bhardwaj PGT(CS)
Example – 4 (Multiple Exception Handling)
Successful Execution