Bird
0
0

What is a good practice when naming a custom exception class in Python?

easy📝 Conceptual Q2 of 15
Python - Custom Exceptions
What is a good practice when naming a custom exception class in Python?
AUse spaces in the class name for clarity
BName it ending with 'Error' to indicate it is an exception
CStart the name with a number
DUse lowercase letters only
Step-by-Step Solution
Solution:
  1. Step 1: Review Python naming conventions for exceptions

    Custom exceptions should be named clearly, usually ending with 'Error' to indicate their purpose.
  2. Step 2: Check invalid naming options

    Class names cannot start with numbers or contain spaces; lowercase is not standard for class names.
  3. Final Answer:

    Name it ending with 'Error' to indicate it is an exception -> Option B
  4. Quick Check:

    Exception class naming = Ends with 'Error' [OK]
Quick Trick: End custom exception names with 'Error' for clarity [OK]
Common Mistakes:
  • Using lowercase or spaces in class names
  • Starting class names with numbers
  • Not indicating it is an error in the name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes