Skip to content

Commit eb58b14

Browse files
Update Exception handling .md
1 parent 447b35d commit eb58b14

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

week_10/Exception handling .md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ Exception handling helps prevent our program from crashing when something goes w
1313

1414
- **`raise` Statement**: You can use the `raise` statement to manually trigger an exception if a certain condition occurs.
1515

16+
# Common Types of Errors (Exceptions) in Python
17+
18+
Python provides many built-in exceptions to handle different types of errors that may occur during runtime.
19+
20+
## ✅ Common Built-in Exceptions
21+
22+
| Error Name | Description |
23+
|------------------------|-------------------------------------------------|
24+
| `ZeroDivisionError` | Raised when division by zero occurs (`10 / 0`) |
25+
| `ValueError` | Raised when an invalid value is used (`int("abc")`) |
26+
| `TypeError` | Raised when an operation is applied to an object of inappropriate type (`"a" + 5`) |
27+
| `IndexError` | Raised when a sequence index is out of range (`list[10]`) |
28+
| `KeyError` | Raised when a dictionary key is not found |
29+
| `NameError` | Raised when a variable is not defined |
30+
| `FileNotFoundError` | Raised when a file or directory is not found |
31+
| `ImportError` | Raised when an imported module cannot be found |
32+
| `AttributeError` | Raised when an invalid attribute reference is made |
33+
| `IndentationError` | Raised due to incorrect indentation |
34+
| `SyntaxError` | Raised when the Python syntax is incorrect |
35+
36+
---
37+
1638
## Example of Exception Handling
1739

1840
```python
@@ -32,4 +54,4 @@ else:
3254
finally:
3355
# Always executes, regardless of exceptions
3456
print("Execution complete.")
35-
```
57+
```

0 commit comments

Comments
 (0)