1 00:00:00,330 --> 00:00:02,250 Hello everybody and welcome back. 2 00:00:02,250 --> 00:00:06,540 And this is the last part of our Python basics tutorial. 3 00:00:06,600 --> 00:00:12,300 Basically right now I just want to show you the try and accept rule which is used when you want to try 4 00:00:12,300 --> 00:00:14,610 something and it keeps out an error. 5 00:00:14,610 --> 00:00:21,000 So in order for our program not to crash after the terror we Randi try and accept command. 6 00:00:21,000 --> 00:00:24,060 It will basically try. 7 00:00:24,260 --> 00:00:27,140 It is basically similar to the if else command. 8 00:00:27,350 --> 00:00:32,750 But right now this is the usage when something can give an error back. 9 00:00:32,750 --> 00:00:41,280 So the most simple program that I can write you that actually makes sense would be the division by zero. 10 00:00:41,390 --> 00:00:47,840 So let's see how we can actually make our program not crash once we divide by zero so let's actually 11 00:00:47,840 --> 00:00:52,960 make a program nano python by tonight. 12 00:00:52,970 --> 00:01:01,120 That is why we run our path to the Python loops. 13 00:01:02,330 --> 00:01:03,710 And let me show you what they mean. 14 00:01:03,740 --> 00:01:10,000 So number one standard program number one equals integer they're all input. 15 00:01:10,130 --> 00:01:11,750 So we already covered all of this. 16 00:01:12,230 --> 00:01:23,740 And enter first number we ask call first number and then number two integer raw input and third second 17 00:01:23,740 --> 00:01:24,770 number. 18 00:01:25,510 --> 00:01:27,230 So we asked for two numbers. 19 00:01:27,280 --> 00:01:34,480 And then what we do basically is actually let's use a simple simple function. 20 00:01:34,490 --> 00:01:38,280 So depth division number one. 21 00:01:38,290 --> 00:01:46,330 Number two and we want to actually just print out the not one. 22 00:01:46,740 --> 00:01:50,890 Well it just looks number one divided by name two. 23 00:01:51,160 --> 00:01:54,250 Which is used with this slash right here. 24 00:01:54,520 --> 00:01:56,320 So that's how you print numbers. 25 00:01:56,320 --> 00:01:58,360 So let me show you what I mean right now. 26 00:01:58,390 --> 00:01:58,690 So. 27 00:01:58,870 --> 00:02:02,610 Oh of course we have to call the function in order for this program to work. 28 00:02:02,620 --> 00:02:06,860 So the function we want to use these to input the numbers. 29 00:02:07,330 --> 00:02:08,150 If you didn't. 30 00:02:08,230 --> 00:02:09,490 If you don't know what functions are. 31 00:02:09,490 --> 00:02:15,280 Make sure to check out the video where I explained it and we want to specify the second number as well. 32 00:02:16,000 --> 00:02:18,780 So control over to save control explains it. 33 00:02:18,910 --> 00:02:20,630 See mode by 9. 34 00:02:21,940 --> 00:02:29,360 And we run by tonight and let's say 3 and 3 and we get the three divided by three equals one. 35 00:02:29,500 --> 00:02:34,190 But what happens once I type three and then zero. 36 00:02:34,480 --> 00:02:42,040 You can see that we get a trace back error and it says zero division error integer division or modulo 37 00:02:42,070 --> 00:02:43,500 by zero. 38 00:02:43,660 --> 00:02:46,830 So we can check out the error that we receive. 39 00:02:46,900 --> 00:02:57,870 Right here we can try to copy it and then we can try to change our our file or our program to not give 40 00:02:57,870 --> 00:02:58,940 this power anymore. 41 00:02:58,950 --> 00:03:00,600 So Python 9 would be. 42 00:03:01,510 --> 00:03:06,720 And right here we will try and we will add the try and accept rule. 43 00:03:06,780 --> 00:03:10,800 So we made our function which will take two numbers as inputs. 44 00:03:10,800 --> 00:03:17,570 And right now what we want to do is basically just type your try then two dots and we want to try this. 45 00:03:17,640 --> 00:03:29,250 And in case that doesn't work and it only one clerk in case of the except in case of the Zero Division 46 00:03:29,340 --> 00:03:38,120 we will just type you accept based on zero division error and then we want to just type here what we 47 00:03:38,120 --> 00:03:38,530 want to do. 48 00:03:38,530 --> 00:03:47,380 So in our case we want to for example print can't divide by zero. 49 00:03:49,220 --> 00:03:51,860 And now let's see how this will work. 50 00:03:51,890 --> 00:04:00,370 So if we run once again 3 3 works but if we want 3 0 it will give us an output or basically it will 51 00:04:00,380 --> 00:04:04,600 printouts print as the string that says can't divide by zero. 52 00:04:04,610 --> 00:04:09,390 Now there is a huge difference between this right here and this right here. 53 00:04:09,530 --> 00:04:15,950 This does close this closes the problem properly and this right here basically crashes the program giving 54 00:04:15,950 --> 00:04:17,740 us the Zero Division error. 55 00:04:18,080 --> 00:04:21,290 So make sure to always at the try and accept the acceptable. 56 00:04:21,290 --> 00:04:28,030 So you don't actually crash your own program with some statement so that be about it for the python 57 00:04:28,040 --> 00:04:34,940 basics in the next tutorials people start creating our own backdoor we covered some really basics right 58 00:04:34,940 --> 00:04:40,820 here such as function classes functions basically while loops. 59 00:04:41,120 --> 00:04:49,490 True or false if ls for and so on and so on we basically call it almost everything we need in details 60 00:04:49,790 --> 00:04:56,420 well not in details we call it as a basic but we will not be doing much harder things in our pectoral 61 00:04:56,420 --> 00:05:00,030 coding so don't be scared for that. 62 00:05:00,170 --> 00:05:04,620 That would be about it for the basics and I hope I see you in the next lecture. 63 00:05:04,620 --> 00:05:08,030 Well Will us start off by planning our backdoor creation. 64 00:05:08,360 --> 00:05:10,970 So I hope I see you there and take care by.