Pythonesque that assertions can be implemented in bichon.
Assertions are statements that assert our state a fact confidently in our program.
So, for example, while writing a division function, we are confident that this is the that should
not be zero.
We know that division by zero is illegal and we asserted deviser is not equal to zero.
Assertions are simply boolean expressions that checks, if the condition returns, is true or not.
So if it is true, the program does nothing and move to the next line of the code.
However, if it is false, the program stops and throws an error.
So that is a basic principle of assertion.
So let me repeat once again for the clarity.
Assertions are simply boolean expression, so it will return true and false that chix in the condition
return is true or not if it if it is the truth.
The program does nothing and move to the next line of the code if the condition is true.
However, if it is false, the program stops and throws an error.
So that is known as the assertion in Baton.
So it is also a debugging tool as it brings the program on hold, as soon as any error is occurred and
shows on which point of the program, the error has occurred.
So that is a special features of assertion.
So previous code is there.
Now we are having that session condition.
If the condition is true, then the program continue to run.
If the condition is false, then the assertion stops the program and gives us an error and also the
respective point where that particular error has occurred.
So that will be mentioned in the assertion error session later.
So for the better, let us go for one practical demonstration will be showing you that how this assertion
can be implemented in Biton.
We know that assertions are statements that assert our state, in fact, confidently in our program,
for example, while writing a deficient function, you are confident that the deviser should not be
zettl.
In the case, we can prove we can insert one assert device that is not equal to zero.
Accordingly.
So assertions are nothing but simply boolean expressions that checks if the condition returns, true
or not, if it is returning to the program does nothing and move to the next line of code.
And if it returns false, the program stops and throws an error known as the assertion.
Edit so as an example, consider this one where defined one function.
The name of the function is Avijit, which will take this marks the least as input document.
So assert.
Lynn Marks is not called digital.
If the condition is true, that means if the length of this list is not equal, that means the list
is not empty.
If the condition is true, then it will go for the sum of marks by laying up the marks to calculate
the average and that will be returned.
So but if that length of marks is not equal to zero, if the condition is false, then it will produce
the assassinator.
So for the first run, we are making one least available, which is non-empty and we are trying to calculate
the average of them and we are going for the next one with the list is empty.
al-Atassi, what is the outcome we are going to have?
So just see, in the first case we are having this 11 plus 22 plus 33 whole battery.
So I'll be teaching with the value.
Twenty two here.
So average of Mach one is equal to twenty two, so average of one is twenty two is getting executed,
is getting printed.
And now in the second case we are passing this, we initializing this mock one with the null list that
is containing new element.
So the length of this mark one will be zero.
So length of Mach one is not equal, digital recognition will be false.
So it will produce one error known as the assassinator.
So that is known as the assassinator.
So not only the throwing the assassinator, also we can put some error message also, so let us go for
that.
So here to see if the ruling Assad land of the Marxist nautical digital, that list is empty.
So the condition is true that Mr. Length of is not legitimate.
That means the list is not empty.
In that case, it will produce true and it will go to the next line without any interruption authorized
assassinator will be will be obtained and it will be having this message to get printed.
So now let me go to execution.
Matou is not all it is having some value there.
So the average will get calculated.
I think as a mark one it is another list.
So I think that here translation error will be thrown.
So just see here.
So average marks of MC2 is 78.
So 78 is the average marks of marks.
But in the case, in the next one, as a mark, one was having the empty list.
So this particular assassinator has taken place.
And here to see the message has got printed, that is a list is empty.
So there is a message you have given this one.
So this giving this message is optional.
You may or may not give as here we have given and but in the previous example, we didn't give any such
error message.
So I think now that what is a solution in Python, the concept is now getting clear to you.
Thanks for watching this video.