Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

Python Exception Handling - tccicomputercoaching.com

Exception can be said to be any abnormal condition in a program resulting to the disruption in the flow of the program.

Exception in a code can also be handled. In case it is not handled, then the code is not executed further and hence execution stops when exception occurs.

Python Exception Handling

Why use Exceptions?

Exceptions are convenient in many ways for handling errors and special conditions in a program. When you think that you have a code which can produce an error then you can use exception handling.

Common Exceptions

  1. ZeroDivisionError: Occurs when a number is divided by zero.
  2. NameError: It occurs when a name is not found. It may be local or global.
  3. IndentationError: If incorrect indentation is given.
  4. IOError: It occurs when Input Output operation fails.
  5. EOFError: It occurs when end of the file is reached and yet operations are being performed.

Syntax:

1. try:

2. malicious code

3. except Exception1:

4. execute code

5. except Exception2:

6. execute code

7. ….

8. ….

9. except ExceptionN:

10. execute code

11. else:

12. In case of no exception, execute the else block code.

To learn more about Python at TCCI

Call us @ 9825618292

Visit us @ www.tccicomputercoaching.com

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s