Interview Question

What are exceptions?

Exceptions represent abnormal conditions and propagate to handlers.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

An exception is an object used to signal that normal execution cannot continue. • Raising an exception searches outward for a matching handler. • Unhandled exceptions terminate the current execution path and display a traceback. • Exception classes form an inheritance hierarchy.

💡 Simple Example

raise ValueError('invalid value')

Output

ValueError: invalid value

⚡ Quick Revision

Exceptions represent abnormal conditions and propagate to handlers.