Now, this makes the ordering consistent and minimizes the likelihood of increasing the frequency mathkour
by chance.
For example, let's say the frequency count for the letters V and then key are all the same for the
string we are trying to score.
Now, let's also say that the four letters in this string have higher frequency count, then VII and
Key and the 18 letters have low frequency code.
So in that case, the eight a.m. and are two points of the frequency.
Mascord because I enon are among the top six most frequent letters, even though they do not appear
more frequently and we engage gain this example strength.
So because the frequency matched only range from zero to 12, these two points can make quite a difference.
But by putting letters of identical frequency in reverse order or an order which minimizes the chances
of scoring a particular letter.
So by arranging the letters in reverse order of oil, we avoid artificially increasing the frequency.
My score lower John's ordering of I envy.
And this is also true if there are 18 letters with higher frequency codes and four letters of the lower
frequency.
So the rebels sort order ensures that again, we don't match any of this frequency letters in English
and again avoid increasing the frequency mathkour by vital point to sort each list of volume and the
frequency.
Two letters in the reverse order.
We need to pass a better pipe and sort function to this.
OK, that will look at how Capozzi functional methods to another function.
So like over here we are done frequency to letters at the index of frequency vanload thought we have
given Wyandot find and reverse is equal to true.
Now we can do this because in Python the functions can be treated as values.
In five, defining a function named system is the same as storing the function definition in a variable
name spam.
Now, for example, if you have to look at the following in the interactive shell, if we go here and
we try to define our function system wherein we are just seeing a print command, see BITD, for example,
and then we call the material, it prints it, or if we say, for example, each one is equal to spam
and then we say even as a function, still it brings title.
So in this example code, we have defined a function name spam that brings the string Bitan.
Now, this also means that the variable spam holds the function definition.
Then we copy the function in this spam variable to a variable event.
And after doing so, we then call even just like we call the spam.
Note that the assignment statement does not include parentheses of the spam.
If it did, it would instead call this spam function and said the variable even to the return value
that gets evaluated from the function.
So since functions are values, we can pass them as arguments and the function.
Again, if we want to just check out something new in this, we would define yourself, do map function,
which is passing here, or parameter functions.
And here we are saying return function would then comma five parts to it.
Then the next thing we define here, adding we pass A comma B here and we see A plus B, then we define
the subtracting and pass again equal.
Maybe this time we see on A minus B, OK.
And then here we say do math.
Now here we are passing, adding we are getting here 15 because it is passing the function as often
as important, five as a parameter and doing in addition.
Similarly, if we say do math and now we see the function that we have as subtracting.
And we get now 10 minus five that fine.
So here we have defined three functions that do math, adding and subtracting.
When we pass function in adding to do or Matkal, we are assigning adding to the variable function and
the function.
Then Gamma five is calling, adding and passing 10 and five to it.
So the function then number five will effectively the same as the call for adding then comma five.
This is my do math adding ratones 15.
Similarly, when we pass subtracting to the do not call do matter protracting returns five because the
function Pancamo five is same as subtracting then comma five coming to the passing of function to this
matter over here.
So here if we are seeing this five is equal to we are having some value CESI, B and E, ok, now we
are seeing standard sort function and then we print, we get it in the value of A, B, C, but if we
pass a function for a key word argument, the value in the list does autobody functions return value.
So when each value in the list is passed to that function, for example, we can also parse the line,
the fine string method as the key to sort of follow like we have done in our program over here.
If you just check this one in, we are passing in the key and the value added.
So when we do that here, OK, let us try and do this in the introduction here.
So here, if we are seeing a Hawaiian is equal to a line and then we pass as each of the c u m w f g,
y, b, b, c, v, e, then we have g, x, q that.
And then we see spam dot sort we are passing is equal to 80 a lion dot find and also we are seeing spam
dot sort is equal to one dot find and then we are saying so now again it's coming in the same order.
Now when we pass it on here, we have given it in capitaland this was once more.
So if we see here say we couldn't see then I'd be sorry.
And now if we see spam dot sort Saiki is equal to say a lion dot find and put into a, C and B because
we have given that C is more frequent then B hence we are sorting it like that.
So when we pass the ID on, not find this sort of sorting the normal string in the alphabetical order,
this sort method for forestalls the fine method on each string so that the line would find a Oresteia
or not find B or find C, return the indexes respectively of each string position in the open string.
The sort then uses these written indexes rather than the original ABC string before the items in this
list.
This is why A, B and C appears to be sorted as ECN B reflecting the order in which they appear in the
line.
OK, now let us continue our discussion of this in the next session.
That's it from the session.
Thank you very much.