Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content


Exception Handling in Python 1


In this section we will see that,

What is exception ?

What is error ?

Which are the different types of exception ?

Which are the terms to handle the exceptions in Python ?


An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instruction.


Errors detected during execution are called exceptions.


In Python there are two distinguishable kinds of errors : syntax errors and exceptions.


Syntax errors, also known as parsing errors.


for i in range(1,10)


Here missing":" after for is syntax error.




10*(1/0) : ZeroDivisionError : division by zero.

4+spam*3 : NameError : name 'spam' is not defined.

'2'+2 : TypeError : Can't convert 'int' object to str implicitly.


Example :




print ('hey2')

O/P :




Exception handling in Python


Eg. n=int(input("Please enter a number:"))

Please enter a number:23.50

Exception occurs like ValueError: invalid literal for int() with base 10: '23.5'


With all the the keywords mentioned below we can handle the exceptions of python -







try :

n=input("Please enter an integer:")


except ValueError:

print("no valid integer! please try again")

print("great!! you successful entered an integer!")


A try statement may have more than one except clause.

But at most one except clause will be executed.


Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere