Exception_Handling_Notes
Exception_Handling_Notes
They can be caused by invalid input, division by zero, trying to open a non-existent file, etc.
2. Types of Errors
Syntax Errors:
• Occur when the rules of Python are not followed.
• Python won’t run the program until you fix these errors.
Exceptions:
• Occur during runtime, even if the syntax is correct.
• TypeError: Using the wrong data type (e.g., adding a string to an integer).
4. Handling Exceptions
Use try and except blocks to handle exceptions.
The try block contains the code that might raise an exception.
6. Example Programs