Question: 1 . Create a Python class named 'InvalidAgeError' that inherits from the built - in 'Exception' class. a . Define an ' _ _ init
Create a Python class named 'InvalidAgeError' that inherits from the builtin 'Exception' class.
a Define an init method within 'InvalidAgeError' to customize the error message.
Implement a function named 'validateage'.
a Define the function to take an 'age' parameter.
b Use a 'try' block to check if the 'age' is less than
i If 'age' is less than raise an instance of 'InvalidAgeError'.
ii If 'age' is not less than print 'Age is valid.
c Use an 'except' block to catch 'InvalidAgeError' and print the custom error message.
Outside the function:
a Call 'validateage' with the following age values.
i validateage
ii validateage
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
