The title of this video is Exception Handling in Python. In computer programming, there are many enemies out there. There are bugs, errors, and just the theater, the unexpected that can show it's unpleasant self in our programs. This enemy is so formidable that it caused software engineers to develop practices to combat them. One strategy is called Exception Handling, which detects anomalies in our program and handles them gracefully. Exceptions occur in various situations, such as a file not existing, memory not being available, or using invalid input. Python supports Exception Handling, and we're going to look at a couple of coding examples to get a better understanding of how they work. Let's take a look at the basic syntax of a try/except statement. We have the try keyword followed by the code block, and then the except block, and when we run this program, absolutely nothing happens. The only use for this code snippet is getting a better understanding of the syntax of a try/except statement. Try is a reserved keyword in Python, and we're going to try to execute the code within this code block. If no error happens, then the control of the program goes to outside of the except block into line 8. However, if an error occurs within the try block than the control of the program will flow to line 6, and this is where the exception is located. We have the except keyword, which like try is a reserved keyword in Python, followed by the Exception class, which in this case is called Exception. In this case, Exception is not a good class to use. The reason being is that it's too general as it's a base class. It's better to use a more concrete class, aka a more specific one. The Python documentation show cases all the concrete classes you can use along with the details. The link to this resource is included within the reading for this module, Exception Handling explained in Python. Let's use a more specific class. Let's say that you want to create a simple number processing program and you want to give the user the ability to divide two integers. Let's go ahead and code an example. In that case, we start off with the try keyword and then we create the try block, and then this is where we'll ask the user to enter in integers. I'm going to create one variable called x and set it equal to int input. Then I'm going to provide some text to the user to enter in a enumerator. Next, we'll create another variable called y, and then we enter in the same syntax. But we go ahead and give the user a different message, "enter in a denominator", and then last but not least, we go ahead and divide the results. But what could go wrong here? In division, if we divide the numerator by zero, then that's an illegal expression. So we can go ahead and process this potential error by including an Except block, except zero division error, and you see how when I type in letters zer, the PyCharm has the auto complete feature for me. So I could just hit enter, and as you can see, the class is implemented. Then within the except block, I'm going to print a message can't divide by zero. Let's go ahead and test this. I'm going to enter in five for the numerator, zero for the denominator, and as we can see, we get can't divide by zero. That error has been processed using the try/except block. Let's take a look at another example. Let's say that we need to do various imports in our program, and we want to ensure that we're not importing a module that doesn't exist. We can again make our program more robust by using an exception. I'm going to create the try block, and then within the try block, I'm going to do an import, import mathx as m. Now, mathx doesn't exist. There's a built-in math module, but again, mathx doesn't exist. So when we run this program, we get an error. I'm just going to add a couple of statements within the try block. Then I'm going to create the except block. So except, and then in this case, ModuleNotFoundError because we want to be very explicit. Print "Module not found". Let's go ahead and test this by first commenting out the previous try/except block and then running this program now. As we can see, the exception has been processed and the print message has been printed. Exception handling is a powerful technique to help us to handle errors. Get more practice with exceptions by completing the lab for this module, add exceptions to these functions.