0% found this document useful (0 votes)
6 views2 pages

Adv Py Theory

Uploaded by

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

Adv Py Theory

Uploaded by

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

Exception Handling :

● Python has many built-in exceptions that are raised when your
program encounters an error.When these exceptions occur, the
Python interpreter stops the current process and passes it to the
calling process until it is handled. If not handled, the program will
crash.

Python try….except - used in python to handle errors and exceptions. The


code in try block runs when there is no error. If the try block catches the
error, then the except block is executed.
Syntax

Output

Finally clause - When we handle exception using the try and except block,
we can include a finally block at the end. The finally block is always
executed, so it is generally used for doing the concluding tasks like closing
file resources or closing database connection or may be ending the
program execution with a delightful message.finally block is in a function
which returns a value.
Syntax
Output 1

Output 2

You might also like