0% found this document useful (0 votes)
4 views1 page

Understanding Runtime Errors and Exceptions

Exceptions are runtime errors that can occur in programs, such as divide by zero and array index out of bounds. They are categorized into synchronous exceptions, which can be controlled by the program, and asynchronous exceptions, which cannot. If exceptions are not handled, the program will terminate and generate error messages.

Uploaded by

sreedhar628
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Understanding Runtime Errors and Exceptions

Exceptions are runtime errors that can occur in programs, such as divide by zero and array index out of bounds. They are categorized into synchronous exceptions, which can be controlled by the program, and asynchronous exceptions, which cannot. If exceptions are not handled, the program will terminate and generate error messages.

Uploaded by

sreedhar628
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exceptions

• Runtime Errors are called Exceptions


• Exceptions are
1. divide by zero
2. array index out of bounds
3. out of memory or out of disk space
4. overflow
5. underflow etc..
• Eexceptions are categorized into two
1. Synchronous Exceptions
2. Asynchronous Exceptions
• Synchronous exceptions (like divide by zero, array index out of bound, etc.) can be
controlled by the program
• Asynchronous exceptions (like an interrupt from the keyboard, hardware malfunction,
disk failure) are beyond the control of the program.
• When an exception occurs in a program, the program must raise the exception. After that
program must handle the exception otherwise the program will be immediately terminated.
• If exceptions are not handled by programs, then error messages are generated..
Example:
num=int(input("enter numerator"))
den=int(input("enter denominator"))
quo=num/den
print(quo)
Output:
enter numerator1
enter denominator0
ERROR!
Traceback (most recent call last):
File "<string>", line 3, in <module>
ZeroDivisionError: division by zero

You might also like