Python Built-in-Exceptions

Python Built-in-Exceptions:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) The built-in-exceptions, such as NameError or SynatxError, are created for reporting specific errors in the code. Built-in-exceptions are common errors that can identify automatically by Python. Python throws an exception when one of these errors is detected. This means a traceback message is generated and the message is printed in the Interactive Window; if the erroneous code is in a script, the script will stop running at that point.

(2) New programmers often encounter Name Error, SyntaxError, and TypeError exceptions. The NameError usually occurs because of a spelling or capitalization mistake in the code. The SyntaxError can occur for many reasons, but the underlying problem is that one of the rules of properly formed Python has been violated. A TypeError occurs when the code attempts to use an operator differently from how it’s designed. For example, code that adds an integer to a string generates a TypeError.

NameError Example:

Python NameError

SyntaxError Example:

Python SyntaxError

TypeError Example:

Python TypeError

Tutorial Python
Tutorial MySQL
Email (Electronic Mail)
Operating System (OS)
Computer Network
Database Models or Data Models
Python Built-in Exceptions– Official Docs

Comments (No)

Leave a Reply