1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
exceptions
errors that occur during execution, usually caused in the environment where the code executes
ValueError
wrong value in specified data type
SyntaxError
violation of Python’s grammar rules
TypeError
two different types are combined
IndexError
index of a sequence doesn’t exist
KeyError
key doesn’t exist in dictionary
ZeroDivisionError
attempt to divide by zero
try
code that may cause errors
except
executes if exception occurs, skipped if not
else
executes if no exception occurs
finally
always executes regardless of exceptions
custom exceptions
defined by subclassing the built-in Exception class
exception chaining
allows you to link a newly raised exception to a previous one; use raise…from
exception groups
handles multiple exceptions simultaneously
context manager
allocates and releases resources precisely when needed
re-raising exceptions
allows you to catch an exception, perform some actions, and re-raise the exception