English

Define the following: Throwing an exception - Computer Science (Python)

Advertisements
Advertisements

Question

Define the following:

Throwing an exception

Short/Brief Note
Advertisements

Solution

Throwing an exception means raising an exception.

Each time an error is detected in a program, the Python interpreter raises (throws) an exception. Exception handlers are designed to execute when a specific exception is raised.

Programmers can also forcefully raise exceptions in a program using the raise and assert statements. Once an exception is raised, no further statement in the current block of code is executed.

raise NameError
assert conditon, "message"
shaalaa.com
Handling Exceptions in Python
  Is there an error in this question or solution?
Chapter 1: Exception Handling in Python - Exercise [Page 17]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 1 Exception Handling in Python
Exercise | Q 5. b) | Page 17
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×