0% found this document useful (0 votes)
48 views8 pages

Exceptions 1

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views8 pages

Exceptions 1

Uploaded by

rahul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Exceptions

Exceptions
• https://docs.python.org/3/library/exceptions.html#bltin-exceptions
• https://www.tutorialsteacher.com/python/exception-handling-in-pyth
on
• https://www.freecodecamp.org/news/exception-handling-python/
Python - Error Types

• The most common reason of an error in a Python program is when a


certain statement is not in accordance with the prescribed usage.
Such an error is called a syntax error. The Python interpreter
immediately reports it, usually along with the reason.
• >>> print "hello"
• SyntaxError: Missing parentheses in call to 'print'. Did you mean
print("hello")?
• In Python 3.x, print is a built-in function and requires parentheses.
The statement above violates this usage and hence syntax error is
displayed.
• Many times though, a program results in an error after it is run even if
it doesn't have any syntax error. Such an error is a runtime error,
called an exception. A number of built-in exceptions are defined in
the Python library. Let's see some common error types.
• The following table lists important built-in exceptions in Python
• >>> a = 5/0
• Traceback (most recent call last):
• File "<pyshell#13>", line 1, in <module>
• a = 5/0
• ZeroDivisionError: division by zero

You might also like