Exception handling is a graceful way to manage execution of a program and display user friendly information when errors occur during execution of the programs.
Let’s look at the below example to get a better understanding. User needs to provide a number to the below program and reverse of the number will be returned.
If the user provides a numerical input the “try block” will be executed and the “finally block” will be executed.

However, if the user provides a non numeric input, an exception error “ValueError” will happen and code will execute the first “except” block and “finally block”.

Similarly if the user provides ‘zero’ as the input, an exception error “ZeroDivisionError” will happen and code will execute the second “except” block and “finally block”.

Cheers!


Anonymous or Lambda Functions are short functions which are generally written in a single line. For example, the below set of codes show you how we can use Lambda function to cube a number, instead of defining a function.












Step 3– Start Jupyter Notebook by clicking on launch button. This will open a new tab in your preferred browser.


You must be logged in to post a comment.