Complete the code to raise a built-in exception when a number is negative.
if number < 0: raise [1]("Negative number not allowed")
ValueError is the built-in exception used to indicate a wrong value, such as a negative number where it is not allowed.
Complete the code to define a custom exception named MyError.
class [1](Exception): pass
Custom exceptions are defined by creating a new class that inherits from Exception. Here, MyError is the custom exception name.
Fix the error in raising the custom exception with a message.
raise [1]("This is a custom error message")
To raise the custom exception, use its class name MyError, which was defined earlier.
Fill both blanks to create a dictionary comprehension that includes only keys with values greater than 10.
filtered = {k: v for k, v in data.items() if v [1] 10 and isinstance(v, [2])}The condition filters values greater than 10 and checks if the value is an integer.
Fill all three blanks to create a custom exception class with a message attribute and raise it.
class [1](Exception): def __init__(self, message): self.[2] = message super().__init__(message) raise [3]("Custom error occurred")
The class name is CustomError. The attribute to store the message is 'message'. The exception is raised using the class name CustomError.