1 00:00:00,070 --> 00:00:03,280 So this we're going to see the exception handling in Python. 2 00:00:03,420 --> 00:00:09,720 So there are some few exceptions you need to handle, say, division by zero. 3 00:00:09,870 --> 00:00:15,700 So let's go to camp physicals to try to do zero. 4 00:00:16,350 --> 00:00:19,260 So now let's execute this one. 5 00:00:22,840 --> 00:00:25,450 So it just doesn't matter it. 6 00:00:26,170 --> 00:00:31,390 So now let's, uh, uh, step into printouts, right? 7 00:00:36,820 --> 00:00:43,750 So you can see we got deal and this principle did not execute, so whenever there is an exception in 8 00:00:43,770 --> 00:00:46,760 Python already language, the program stops at that point. 9 00:00:46,900 --> 00:00:51,330 So you need to handle that exception and pass through that exception to Utah. 10 00:00:52,330 --> 00:00:58,840 So what you're gonna do is you want to separate and you need to put the internation. 11 00:01:00,740 --> 00:01:05,210 But this one and that system is equal to. 12 00:01:08,470 --> 00:01:09,200 2.0. 13 00:01:09,640 --> 00:01:17,380 So whenever there is an exception and you need to catch that using this, except so except you need 14 00:01:17,380 --> 00:01:25,980 to specify the error or the exception you want to, and that is the general, as you can see, the order, 15 00:01:26,110 --> 00:01:29,020 which suggests to me the reason I wrote. 16 00:01:32,230 --> 00:01:44,230 And I can put the record and I can print so so zero either has been accurate and to just divide by zero 17 00:01:44,230 --> 00:01:45,010 is not possible. 18 00:01:48,990 --> 00:01:51,920 So now let's go ahead and run this group, sorry. 19 00:01:54,960 --> 00:02:04,210 They can see my output has been printed because the script does not stop there, only then you can see 20 00:02:04,210 --> 00:02:05,000 the print statement. 21 00:02:05,020 --> 00:02:13,630 Now, I can also say I can write my code in this except work, but you cannot write the code of another 22 00:02:13,630 --> 00:02:14,320 Ruckersville. 23 00:02:14,800 --> 00:02:20,790 So that's just before going to writing other code, you need to say as yet. 24 00:02:21,250 --> 00:02:30,610 So you can also catch this activation as an object and you can just print feedback on the class so it 25 00:02:30,610 --> 00:02:33,400 will print out the what type of error we have got. 26 00:02:36,490 --> 00:02:39,640 So we can also say that accept that solution. 27 00:02:40,240 --> 00:02:44,800 So this is this will go to all the exceptions and it will print whatever exception you have got. 28 00:02:45,670 --> 00:02:50,550 And see, you have got the general you can only to mention any of these. 29 00:02:50,610 --> 00:02:58,120 Also, this is like a binary catching every other exception you can just to say pass here. 30 00:02:59,820 --> 00:03:03,580 So this is how you handle the roses in the tree except rock. 31 00:03:03,930 --> 00:03:10,730 So if there is no error in this tree and you want to execute some of the code, you can put the else 32 00:03:10,770 --> 00:03:11,280 block. 33 00:03:12,390 --> 00:03:16,050 So you want to try this code and there are any exceptions. 34 00:03:16,200 --> 00:03:20,210 You are going to this except rock, unless you want to go to this block. 35 00:03:21,360 --> 00:03:22,800 It's a pretty tough. 36 00:03:27,310 --> 00:03:39,160 And to to to sort of run the script, we got the one, so we have executed some other instead of this 37 00:03:39,160 --> 00:03:44,820 exceptionally successfully or come with this exception. 38 00:03:45,760 --> 00:03:47,140 And there is another thing. 39 00:03:47,170 --> 00:03:53,980 Finally, and this block will execute, however, if you got any exception are not. 40 00:04:00,740 --> 00:04:03,810 So he's like a distracter in any other. 41 00:04:03,830 --> 00:04:09,620 So I do not I should not the structure, the shuttle, but it's doing the thing. 42 00:04:10,040 --> 00:04:17,420 It will run, uh, after the patankar, so it will run as a final rock. 43 00:04:18,260 --> 00:04:24,530 And if I run this, no matter what, if I got exceptional, not this final rocket, you can see I am 44 00:04:24,530 --> 00:04:25,090 going to execute. 45 00:04:25,530 --> 00:04:27,100 Now let's change it to zero. 46 00:04:27,410 --> 00:04:36,570 Now we will get the exception and how we found that we got exception because this is not like that, 47 00:04:36,620 --> 00:04:43,780 because we got the exception and we just passed it over and the final rule has been executed. 48 00:04:44,030 --> 00:04:49,910 So this finally block is used to release some resources, I suppose, in trying to open a file. 49 00:04:50,030 --> 00:04:51,670 And you can close this in here. 50 00:04:51,800 --> 00:04:59,770 So to make sure that our resources are crossette efficiently so that all the basics of what is exceptionally 51 00:04:59,780 --> 00:05:02,210 dry except and certain finally. 52 00:05:02,720 --> 00:05:09,950 So, you know, it's just easier to, uh, catch all the exceptions and pass through this. 53 00:05:10,280 --> 00:05:13,900 So we do not deal with any other exceptions as well. 54 00:05:14,990 --> 00:05:17,700 So these are about the basics of the exception handling. 55 00:05:17,810 --> 00:05:18,890 I hope I have understood.