Python Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 1)
1.
In Python, what is the purpose of the assert statement?
To handle exceptions
To define custom exception classes
To check if a condition is True, otherwise raise an AssertionError
To terminate the program immediately
Answer: Option
Explanation:
The assert statement is used to check if a condition is True. If the condition is False, it raises an AssertionError, allowing you to catch unexpected conditions during development.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.