SlideShare a Scribd company logo
Exceptions
Definition
An exception is a runtime error which can be handled by the
programmer. That means if the programmer can guess an error in the
program and he can do something to eliminate the harm caused by
that error then it is called an exception. If error is not handled by
programmer then it is called as error.
All exceptions are represented as classes in python. The exceptions
which are already available in python are called built-in exception.
Important exception classes in python
BaseException
Exception
StandardError Warning
DeprecationWarning
RuntimeWarning
ImportWarning
AssertionError
SyntaxError
TypeError
EOFError
RuntimeError
ImportError
ArthmeticError
NameError
Exception Handling
Purpose of handling errors is to make program robust. It means strong.
Robust program does not terminate in the middle. When there is a error
displays appropriate message to the user and continue execution. When
the errors can be handled they are called exception.
To handle the exception the programmer should perform the following
three steps
Step1: The statement that may cause the exception must be written inside
a ‘try’ block
try:
statements
If statement raises an error then it enters into except block otherwise
continues the execution
continued
Step2:Programmer should write except block where we should display the exception details to the
user
except exception name:
statements #these statements from handler
Step3:Lastly the programmer should perform clean up actions like closing the files and terminating
any other processes which are running.
finally:
statements
Statements inside the finally block are executed irrespective of whether there is an exception or
not. This ensures that all the opened files are properly closed and all the running processes are
terminated properly.
Syntax for handling exception
try:
statements
except Exception1:
exception handler1
except Exception2:
exception handler2
else:
statements
finally:
statements
Types of Exception
Exception Class Name Description
Exception Represents any type of exception. All exception are sub classes of this class
ArithmeticError Represents the base class for arithmetic errors like OverflowError,
ZeroDivisionError, FloatingPointError
AssertionError Raised when an assert statement gives error
AttributeError Raised when an attribute reference or assignment fails
EOFError Raised when input() function reaches end of file condition without reading any
data
FloatingPointError Raised when a floating operation fails
GeneratorExit Raised when generators close() method is called
IOError Raised when an input or output operation failed. It raises when the file opened is
not found or when writing data disk is full
ImportError Raised when an import statement fails to find the module being imported
continued
Exception Class Name Description
IndexError Raised when a sequence index or subscript is out of range
KeyError Raised when a mapping (dictionary) key is not found in the set of existing
keys
KeyboardInterrupt Raised when the user hits the interrupt key(Control-C, Delete)
NameError Raised when an identifier is not found locally or globally
NotImplementedError Derived from runtimeError
Programs on exception
Python program to handle ZeroDivisionError exception
Filename:ep1.py
Python program to handle syntax error given by eval() function
Filename:ep2.py
Python program to handle multiple exception
Filename:ep3.py
User Defined Exception
Like the built in exceptions of python user can also create his own
exceptions which are called user defined exception or custom exception.
EXAMPLE: Matainance of minimum balance in account
Steps to define user defined exception
1.Create own exception class and is sub class of built in class Exception
class MyExecption(Exception):
def __init__(self,arg):
self.msg=arg
msg is member of class MyException and is assigned with parameter
received from outside
Continued
2. When the programmer suspects the possibility of exception raise own
exception using raise statement
Raise MyExecption(‘message’)
3. Programmer must write the code inside a try block and catch the
exception using except block as
try:
code
except MyException as me
print(me)
Python program to illustrate user defined exception
Filename:ep4.py
THANK YOU

More Related Content

Similar to EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING (20)

Python Unit II.pptx
Python Unit II.pptxPython Unit II.pptx
Python Unit II.pptx
sarthakgithub
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
Megha V
 
Exception Handling on 22nd March 2022.ppt
Exception Handling on 22nd March 2022.pptException Handling on 22nd March 2022.ppt
Exception Handling on 22nd March 2022.ppt
Raja Ram Dutta
 
Exception Handling
Exception HandlingException Handling
Exception Handling
baabtra.com - No. 1 supplier of quality freshers
 
Python Lecture 7
Python Lecture 7Python Lecture 7
Python Lecture 7
Inzamam Baig
 
Python_Exception_Handling_Presentation.pptx
Python_Exception_Handling_Presentation.pptxPython_Exception_Handling_Presentation.pptx
Python_Exception_Handling_Presentation.pptx
csanilram
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
Pavan326406
 
Exception
ExceptionException
Exception
Navaneethan Naveen
 
Exception handling.pptxnn h
Exception handling.pptxnn                                        hException handling.pptxnn                                        h
Exception handling.pptxnn h
sabarivelan111007
 
Python Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and AssertionsPython Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and Assertions
Ranel Padon
 
Python Exceptions Powerpoint Presentation
Python Exceptions Powerpoint PresentationPython Exceptions Powerpoint Presentation
Python Exceptions Powerpoint Presentation
mitchellblack733
 
Exception handling.pptx
Exception handling.pptxException handling.pptx
Exception handling.pptx
NISHASOMSCS113
 
Exception handling in python
Exception handling in pythonException handling in python
Exception handling in python
Lifna C.S
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
Praveen M Jigajinni
 
Exception Handling in Python topic .pptx
Exception Handling in Python topic .pptxException Handling in Python topic .pptx
Exception Handling in Python topic .pptx
mitu4846t
 
Exception handling in python and how to handle it
Exception handling in python and how to handle itException handling in python and how to handle it
Exception handling in python and how to handle it
s6901412
 
Mastering Errors and Exceptions in Python: A Comprehensive Guide
Mastering Errors and Exceptions in Python: A Comprehensive GuideMastering Errors and Exceptions in Python: A Comprehensive Guide
Mastering Errors and Exceptions in Python: A Comprehensive Guide
Vignan's Foundation for Science, Technology & Research (Deemed to be University)
 
Wondershare UniConverter Crack FREE Download 2025 version
Wondershare UniConverter Crack FREE Download 2025 versionWondershare UniConverter Crack FREE Download 2025 version
Wondershare UniConverter Crack FREE Download 2025 version
mu394968
 
Exception Handling using Python Libraries
Exception Handling using Python LibrariesException Handling using Python Libraries
Exception Handling using Python Libraries
mmvrm
 
Python Unit II.pptx
Python Unit II.pptxPython Unit II.pptx
Python Unit II.pptx
sarthakgithub
 
Python Exception Handling
Python Exception HandlingPython Exception Handling
Python Exception Handling
Megha V
 
Exception Handling on 22nd March 2022.ppt
Exception Handling on 22nd March 2022.pptException Handling on 22nd March 2022.ppt
Exception Handling on 22nd March 2022.ppt
Raja Ram Dutta
 
Python Lecture 7
Python Lecture 7Python Lecture 7
Python Lecture 7
Inzamam Baig
 
Python_Exception_Handling_Presentation.pptx
Python_Exception_Handling_Presentation.pptxPython_Exception_Handling_Presentation.pptx
Python_Exception_Handling_Presentation.pptx
csanilram
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
Pavan326406
 
Exception handling.pptxnn h
Exception handling.pptxnn                                        hException handling.pptxnn                                        h
Exception handling.pptxnn h
sabarivelan111007
 
Python Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and AssertionsPython Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and Assertions
Ranel Padon
 
Python Exceptions Powerpoint Presentation
Python Exceptions Powerpoint PresentationPython Exceptions Powerpoint Presentation
Python Exceptions Powerpoint Presentation
mitchellblack733
 
Exception handling.pptx
Exception handling.pptxException handling.pptx
Exception handling.pptx
NISHASOMSCS113
 
Exception handling in python
Exception handling in pythonException handling in python
Exception handling in python
Lifna C.S
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
Praveen M Jigajinni
 
Exception Handling in Python topic .pptx
Exception Handling in Python topic .pptxException Handling in Python topic .pptx
Exception Handling in Python topic .pptx
mitu4846t
 
Exception handling in python and how to handle it
Exception handling in python and how to handle itException handling in python and how to handle it
Exception handling in python and how to handle it
s6901412
 
Wondershare UniConverter Crack FREE Download 2025 version
Wondershare UniConverter Crack FREE Download 2025 versionWondershare UniConverter Crack FREE Download 2025 version
Wondershare UniConverter Crack FREE Download 2025 version
mu394968
 
Exception Handling using Python Libraries
Exception Handling using Python LibrariesException Handling using Python Libraries
Exception Handling using Python Libraries
mmvrm
 

More from NagarathnaRajur2 (20)

C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVBasics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt  BASIC WITH DEPTH CONTENTlecture-ON-C.ppt  BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
NagarathnaRajur2
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICALOPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMINGOOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
NagarathnaRajur2
 
ppt on arm memory.pptx yjjghjghjjjjjjjj
ppt on arm memory.pptx   yjjghjghjjjjjjjjppt on arm memory.pptx   yjjghjghjjjjjjjj
ppt on arm memory.pptx yjjghjghjjjjjjjj
NagarathnaRajur2
 
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
NagarathnaRajur2
 
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
PM.ppt DATA STRUCTURE USING C    WITH EXAMPLE PROGRAMESPM.ppt DATA STRUCTURE USING C    WITH EXAMPLE PROGRAMES
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
NagarathnaRajur2
 
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
NagarathnaRajur2
 
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
Chapter_04_ARM_Assembly.pptx   ARM ASSEMBLY CODEChapter_04_ARM_Assembly.pptx   ARM ASSEMBLY CODE
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
NagarathnaRajur2
 
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
MEMORY.ppt 8051/8052  MEMORY MANEGEMENT MEMORY DESCRIPTIONMEMORY.ppt 8051/8052  MEMORY MANEGEMENT MEMORY DESCRIPTION
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
NagarathnaRajur2
 
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
CHAPTER1.pptx  ON 8051 MICROCONTROLLER INTRODUCTION CHAPTERCHAPTER1.pptx  ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
NagarathnaRajur2
 
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptxCore-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
NagarathnaRajur2
 
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
review.pptx  mnbmnbm,nb,n,nm,mn,mn,n,nm,review.pptx  mnbmnbm,nb,n,nm,mn,mn,n,nm,
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
NagarathnaRajur2
 
IOT introduction with applications ffffffffffffffffffffff
IOT introduction with applications ffffffffffffffffffffffIOT introduction with applications ffffffffffffffffffffff
IOT introduction with applications ffffffffffffffffffffff
NagarathnaRajur2
 
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
CORE JAVA PPT FOR ENGINEERS  BBBBBBBBBBBBBBBBBBBCORE JAVA PPT FOR ENGINEERS  BBBBBBBBBBBBBBBBBBB
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
NagarathnaRajur2
 
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS  BBBBBBBBBBBBBBBBBBBJAVA CLASS PPT FOR ENGINEERING STUDENTS  BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
NagarathnaRajur2
 
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
JavaSteps. PPT  NBNBVNBNVBNNNNNNNNNNNNNNJavaSteps. PPT  NBNBVNBNVBNNNNNNNNNNNNNN
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
NagarathnaRajur2
 
JAVA METHODS PRESENTATION WITH EXAMPLES DFDFFD FDGFDGDFG FGGF
JAVA METHODS PRESENTATION WITH EXAMPLES  DFDFFD   FDGFDGDFG   FGGFJAVA METHODS PRESENTATION WITH EXAMPLES  DFDFFD   FDGFDGDFG   FGGF
JAVA METHODS PRESENTATION WITH EXAMPLES DFDFFD FDGFDGDFG FGGF
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVBasics of C.ppt  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
NagarathnaRajur2
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
NagarathnaRajur2
 
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt  BASIC WITH DEPTH CONTENTlecture-ON-C.ppt  BASIC WITH DEPTH CONTENT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
NagarathnaRajur2
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICALOPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMINGOOPS-PYTHON.pptx    OOPS IN PYTHON APPLIED PROGRAMMING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
NagarathnaRajur2
 
ppt on arm memory.pptx yjjghjghjjjjjjjj
ppt on arm memory.pptx   yjjghjghjjjjjjjjppt on arm memory.pptx   yjjghjghjjjjjjjj
ppt on arm memory.pptx yjjghjghjjjjjjjj
NagarathnaRajur2
 
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
NagarathnaRajur2
 
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
PM.ppt DATA STRUCTURE USING C    WITH EXAMPLE PROGRAMESPM.ppt DATA STRUCTURE USING C    WITH EXAMPLE PROGRAMES
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
NagarathnaRajur2
 
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
NagarathnaRajur2
 
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
Chapter_04_ARM_Assembly.pptx   ARM ASSEMBLY CODEChapter_04_ARM_Assembly.pptx   ARM ASSEMBLY CODE
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
NagarathnaRajur2
 
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
MEMORY.ppt 8051/8052  MEMORY MANEGEMENT MEMORY DESCRIPTIONMEMORY.ppt 8051/8052  MEMORY MANEGEMENT MEMORY DESCRIPTION
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
NagarathnaRajur2
 
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
CHAPTER1.pptx  ON 8051 MICROCONTROLLER INTRODUCTION CHAPTERCHAPTER1.pptx  ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
NagarathnaRajur2
 
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptxCore-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
NagarathnaRajur2
 
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
review.pptx  mnbmnbm,nb,n,nm,mn,mn,n,nm,review.pptx  mnbmnbm,nb,n,nm,mn,mn,n,nm,
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
NagarathnaRajur2
 
IOT introduction with applications ffffffffffffffffffffff
IOT introduction with applications ffffffffffffffffffffffIOT introduction with applications ffffffffffffffffffffff
IOT introduction with applications ffffffffffffffffffffff
NagarathnaRajur2
 
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
CORE JAVA PPT FOR ENGINEERS  BBBBBBBBBBBBBBBBBBBCORE JAVA PPT FOR ENGINEERS  BBBBBBBBBBBBBBBBBBB
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
NagarathnaRajur2
 
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS  BBBBBBBBBBBBBBBBBBBJAVA CLASS PPT FOR ENGINEERING STUDENTS  BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
NagarathnaRajur2
 
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
JavaSteps. PPT  NBNBVNBNVBNNNNNNNNNNNNNNJavaSteps. PPT  NBNBVNBNVBNNNNNNNNNNNNNN
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
NagarathnaRajur2
 
JAVA METHODS PRESENTATION WITH EXAMPLES DFDFFD FDGFDGDFG FGGF
JAVA METHODS PRESENTATION WITH EXAMPLES  DFDFFD   FDGFDGDFG   FGGFJAVA METHODS PRESENTATION WITH EXAMPLES  DFDFFD   FDGFDGDFG   FGGF
JAVA METHODS PRESENTATION WITH EXAMPLES DFDFFD FDGFDGDFG FGGF
NagarathnaRajur2
 
Ad

Recently uploaded (20)

Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..
faizanaltaf231
 
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
How to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time OffHow to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time Off
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..
faizanaltaf231
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
How to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time OffHow to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time Off
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Ad

EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING

  • 2. Definition An exception is a runtime error which can be handled by the programmer. That means if the programmer can guess an error in the program and he can do something to eliminate the harm caused by that error then it is called an exception. If error is not handled by programmer then it is called as error. All exceptions are represented as classes in python. The exceptions which are already available in python are called built-in exception.
  • 3. Important exception classes in python BaseException Exception StandardError Warning DeprecationWarning RuntimeWarning ImportWarning AssertionError SyntaxError TypeError EOFError RuntimeError ImportError ArthmeticError NameError
  • 4. Exception Handling Purpose of handling errors is to make program robust. It means strong. Robust program does not terminate in the middle. When there is a error displays appropriate message to the user and continue execution. When the errors can be handled they are called exception. To handle the exception the programmer should perform the following three steps Step1: The statement that may cause the exception must be written inside a ‘try’ block try: statements If statement raises an error then it enters into except block otherwise continues the execution
  • 5. continued Step2:Programmer should write except block where we should display the exception details to the user except exception name: statements #these statements from handler Step3:Lastly the programmer should perform clean up actions like closing the files and terminating any other processes which are running. finally: statements Statements inside the finally block are executed irrespective of whether there is an exception or not. This ensures that all the opened files are properly closed and all the running processes are terminated properly.
  • 6. Syntax for handling exception try: statements except Exception1: exception handler1 except Exception2: exception handler2 else: statements finally: statements
  • 7. Types of Exception Exception Class Name Description Exception Represents any type of exception. All exception are sub classes of this class ArithmeticError Represents the base class for arithmetic errors like OverflowError, ZeroDivisionError, FloatingPointError AssertionError Raised when an assert statement gives error AttributeError Raised when an attribute reference or assignment fails EOFError Raised when input() function reaches end of file condition without reading any data FloatingPointError Raised when a floating operation fails GeneratorExit Raised when generators close() method is called IOError Raised when an input or output operation failed. It raises when the file opened is not found or when writing data disk is full ImportError Raised when an import statement fails to find the module being imported
  • 8. continued Exception Class Name Description IndexError Raised when a sequence index or subscript is out of range KeyError Raised when a mapping (dictionary) key is not found in the set of existing keys KeyboardInterrupt Raised when the user hits the interrupt key(Control-C, Delete) NameError Raised when an identifier is not found locally or globally NotImplementedError Derived from runtimeError
  • 9. Programs on exception Python program to handle ZeroDivisionError exception Filename:ep1.py Python program to handle syntax error given by eval() function Filename:ep2.py Python program to handle multiple exception Filename:ep3.py
  • 10. User Defined Exception Like the built in exceptions of python user can also create his own exceptions which are called user defined exception or custom exception. EXAMPLE: Matainance of minimum balance in account Steps to define user defined exception 1.Create own exception class and is sub class of built in class Exception class MyExecption(Exception): def __init__(self,arg): self.msg=arg msg is member of class MyException and is assigned with parameter received from outside
  • 11. Continued 2. When the programmer suspects the possibility of exception raise own exception using raise statement Raise MyExecption(‘message’) 3. Programmer must write the code inside a try block and catch the exception using except block as try: code except MyException as me print(me) Python program to illustrate user defined exception Filename:ep4.py