Hello everybody and welcome back.
And this is the last part of our Python basics tutorial.
Basically right now I just want to show you the try and accept rule which is used when you want to try
something and it keeps out an error.
So in order for our program not to crash after the terror we Randi try and accept command.
It will basically try.
It is basically similar to the if else command.
But right now this is the usage when something can give an error back.
So the most simple program that I can write you that actually makes sense would be the division by zero.
So let's see how we can actually make our program not crash once we divide by zero so let's actually
make a program nano python by tonight.
That is why we run our path to the Python loops.
And let me show you what they mean.
So number one standard program number one equals integer they're all input.
So we already covered all of this.
And enter first number we ask call first number and then number two integer raw input and third second
number.
So we asked for two numbers.
And then what we do basically is actually let's use a simple simple function.
So depth division number one.
Number two and we want to actually just print out the not one.
Well it just looks number one divided by name two.
Which is used with this slash right here.
So that's how you print numbers.
So let me show you what I mean right now.
So.
Oh of course we have to call the function in order for this program to work.
So the function we want to use these to input the numbers.
If you didn't.
If you don't know what functions are.
Make sure to check out the video where I explained it and we want to specify the second number as well.
So control over to save control explains it.
See mode by 9.
And we run by tonight and let's say 3 and 3 and we get the three divided by three equals one.
But what happens once I type three and then zero.
You can see that we get a trace back error and it says zero division error integer division or modulo
by zero.
So we can check out the error that we receive.
Right here we can try to copy it and then we can try to change our our file or our program to not give
this power anymore.
So Python 9 would be.
And right here we will try and we will add the try and accept rule.
So we made our function which will take two numbers as inputs.
And right now what we want to do is basically just type your try then two dots and we want to try this.
And in case that doesn't work and it only one clerk in case of the except in case of the Zero Division
we will just type you accept based on zero division error and then we want to just type here what we
want to do.
So in our case we want to for example print can't divide by zero.
And now let's see how this will work.
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
printouts print as the string that says can't divide by zero.
Now there is a huge difference between this right here and this right here.
This does close this closes the problem properly and this right here basically crashes the program giving
us the Zero Division error.
So make sure to always at the try and accept the acceptable.
So you don't actually crash your own program with some statement so that be about it for the python
basics in the next tutorials people start creating our own backdoor we covered some really basics right
here such as function classes functions basically while loops.
True or false if ls for and so on and so on we basically call it almost everything we need in details
well not in details we call it as a basic but we will not be doing much harder things in our pectoral
coding so don't be scared for that.
That would be about it for the basics and I hope I see you in the next lecture.
Well Will us start off by planning our backdoor creation.
So I hope I see you there and take care by.