1/9
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What are the three main types of errors you need to recognize in Python?
Syntax errors, Runtime errors (Exceptions), and Logic errors.
In a try...except block, what is the role of the try block?
It contains the "risky" code that might potentially raise an exception.
When does the else block execute in exception handling?
Only if no exceptions were raised in the try block.
What is the primary purpose of the finally block?
To execute code regardless of whether an exception occurred or not.
How do you manually trigger an error in your code?
Use the raise keyword.
Which keyword is used in unit testing to check if a condition is true?
assert (e.g., assertEqual, assertTrue).
Why is it considered "bad practice" to use a "bare except" (just except:)
It catches every possible error, including system-exiting signals like KeyboardInterrupt.
If you want to catch two specific errors, like ZeroDivisionError and TypeError, in a single block, how would you write it?
except (ZeroDivisionError, TypeError):
What is a "Logic Error," and why is it often the hardest to fix?
A logic error is a mistake in the program's intended behavior.
Which standard library module is used for creating and running unit tests in Python?
unittest