# write a python program to check for ZeroDivisionError Exception.
try:
numerator = int(input("Enter the numerator: "))
denominator = int(input("Enter the denominator: "))
result = numerator / denominator
print("Result:", result)
except ZeroDivisionError:
print("Error: Cannot divide by zero.")
except ValueError:
print("Error: Please enter valid integers.")
# Write a python program to create user defined exception that will check whether the password is correct or not?
class IncorrectPasswordError(Exception):
pass
def authenticate(password):
correct_password = "correct_password"
if password != correct_password:
raise IncorrectPasswordError("Incorrect password")
try:
password_attempt = input("Enter your password: ")
authenticate(password_attempt)
print("Login successful!")
except IncorrectPasswordError as e:
print(e)