1 00:00:00,300 --> 00:00:06,720 Now, this makes the ordering consistent and minimizes the likelihood of increasing the frequency mathkour 2 00:00:06,720 --> 00:00:07,440 by chance. 3 00:00:07,980 --> 00:00:14,010 For example, let's say the frequency count for the letters V and then key are all the same for the 4 00:00:14,010 --> 00:00:15,630 string we are trying to score. 5 00:00:15,990 --> 00:00:23,160 Now, let's also say that the four letters in this string have higher frequency count, then VII and 6 00:00:23,160 --> 00:00:26,510 Key and the 18 letters have low frequency code. 7 00:00:26,790 --> 00:00:31,950 So in that case, the eight a.m. and are two points of the frequency. 8 00:00:31,950 --> 00:00:37,920 Mascord because I enon are among the top six most frequent letters, even though they do not appear 9 00:00:37,920 --> 00:00:40,850 more frequently and we engage gain this example strength. 10 00:00:40,890 --> 00:00:47,180 So because the frequency matched only range from zero to 12, these two points can make quite a difference. 11 00:00:47,490 --> 00:00:54,450 But by putting letters of identical frequency in reverse order or an order which minimizes the chances 12 00:00:54,450 --> 00:00:56,650 of scoring a particular letter. 13 00:00:56,760 --> 00:01:03,540 So by arranging the letters in reverse order of oil, we avoid artificially increasing the frequency. 14 00:01:03,540 --> 00:01:07,230 My score lower John's ordering of I envy. 15 00:01:07,230 --> 00:01:13,230 And this is also true if there are 18 letters with higher frequency codes and four letters of the lower 16 00:01:13,230 --> 00:01:13,830 frequency. 17 00:01:14,340 --> 00:01:21,540 So the rebels sort order ensures that again, we don't match any of this frequency letters in English 18 00:01:21,810 --> 00:01:27,690 and again avoid increasing the frequency mathkour by vital point to sort each list of volume and the 19 00:01:27,690 --> 00:01:28,230 frequency. 20 00:01:28,230 --> 00:01:31,400 Two letters in the reverse order. 21 00:01:31,550 --> 00:01:35,460 We need to pass a better pipe and sort function to this. 22 00:01:35,800 --> 00:01:39,690 OK, that will look at how Capozzi functional methods to another function. 23 00:01:40,020 --> 00:01:46,590 So like over here we are done frequency to letters at the index of frequency vanload thought we have 24 00:01:46,590 --> 00:01:50,560 given Wyandot find and reverse is equal to true. 25 00:01:50,790 --> 00:01:56,430 Now we can do this because in Python the functions can be treated as values. 26 00:01:56,430 --> 00:02:02,760 In five, defining a function named system is the same as storing the function definition in a variable 27 00:02:02,760 --> 00:02:03,450 name spam. 28 00:02:03,960 --> 00:02:10,380 Now, for example, if you have to look at the following in the interactive shell, if we go here and 29 00:02:10,380 --> 00:02:19,230 we try to define our function system wherein we are just seeing a print command, see BITD, for example, 30 00:02:19,590 --> 00:02:27,210 and then we call the material, it prints it, or if we say, for example, each one is equal to spam 31 00:02:27,720 --> 00:02:32,340 and then we say even as a function, still it brings title. 32 00:02:32,370 --> 00:02:37,440 So in this example code, we have defined a function name spam that brings the string Bitan. 33 00:02:37,950 --> 00:02:42,810 Now, this also means that the variable spam holds the function definition. 34 00:02:43,170 --> 00:02:46,850 Then we copy the function in this spam variable to a variable event. 35 00:02:46,860 --> 00:02:50,490 And after doing so, we then call even just like we call the spam. 36 00:02:50,850 --> 00:02:55,230 Note that the assignment statement does not include parentheses of the spam. 37 00:02:55,620 --> 00:03:01,260 If it did, it would instead call this spam function and said the variable even to the return value 38 00:03:01,260 --> 00:03:03,370 that gets evaluated from the function. 39 00:03:03,540 --> 00:03:07,590 So since functions are values, we can pass them as arguments and the function. 40 00:03:08,130 --> 00:03:16,170 Again, if we want to just check out something new in this, we would define yourself, do map function, 41 00:03:16,500 --> 00:03:20,540 which is passing here, or parameter functions. 42 00:03:20,880 --> 00:03:27,210 And here we are saying return function would then comma five parts to it. 43 00:03:27,370 --> 00:03:40,020 Then the next thing we define here, adding we pass A comma B here and we see A plus B, then we define 44 00:03:40,020 --> 00:03:43,950 the subtracting and pass again equal. 45 00:03:43,950 --> 00:03:49,280 Maybe this time we see on A minus B, OK. 46 00:03:49,500 --> 00:03:51,610 And then here we say do math. 47 00:03:52,860 --> 00:04:01,980 Now here we are passing, adding we are getting here 15 because it is passing the function as often 48 00:04:02,010 --> 00:04:05,070 as important, five as a parameter and doing in addition. 49 00:04:05,340 --> 00:04:10,800 Similarly, if we say do math and now we see the function that we have as subtracting. 50 00:04:15,260 --> 00:04:19,280 And we get now 10 minus five that fine. 51 00:04:19,700 --> 00:04:24,590 So here we have defined three functions that do math, adding and subtracting. 52 00:04:24,800 --> 00:04:31,280 When we pass function in adding to do or Matkal, we are assigning adding to the variable function and 53 00:04:31,280 --> 00:04:31,790 the function. 54 00:04:31,790 --> 00:04:35,440 Then Gamma five is calling, adding and passing 10 and five to it. 55 00:04:35,870 --> 00:04:41,250 So the function then number five will effectively the same as the call for adding then comma five. 56 00:04:41,660 --> 00:04:44,100 This is my do math adding ratones 15. 57 00:04:44,210 --> 00:04:50,600 Similarly, when we pass subtracting to the do not call do matter protracting returns five because the 58 00:04:50,600 --> 00:04:57,440 function Pancamo five is same as subtracting then comma five coming to the passing of function to this 59 00:04:57,740 --> 00:04:58,670 matter over here. 60 00:04:58,910 --> 00:05:08,780 So here if we are seeing this five is equal to we are having some value CESI, B and E, ok, now we 61 00:05:08,780 --> 00:05:16,310 are seeing standard sort function and then we print, we get it in the value of A, B, C, but if we 62 00:05:16,310 --> 00:05:23,420 pass a function for a key word argument, the value in the list does autobody functions return value. 63 00:05:23,750 --> 00:05:29,410 So when each value in the list is passed to that function, for example, we can also parse the line, 64 00:05:29,720 --> 00:05:35,830 the fine string method as the key to sort of follow like we have done in our program over here. 65 00:05:36,200 --> 00:05:41,600 If you just check this one in, we are passing in the key and the value added. 66 00:05:42,200 --> 00:05:47,900 So when we do that here, OK, let us try and do this in the introduction here. 67 00:05:48,230 --> 00:06:03,620 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, 68 00:06:03,800 --> 00:06:10,720 y, b, b, c, v, e, then we have g, x, q that. 69 00:06:11,360 --> 00:06:26,240 And then we see spam dot sort we are passing is equal to 80 a lion dot find and also we are seeing spam 70 00:06:27,500 --> 00:06:39,840 dot sort is equal to one dot find and then we are saying so now again it's coming in the same order. 71 00:06:40,100 --> 00:06:45,580 Now when we pass it on here, we have given it in capitaland this was once more. 72 00:06:45,890 --> 00:06:52,300 So if we see here say we couldn't see then I'd be sorry. 73 00:06:53,600 --> 00:07:10,130 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 74 00:07:10,130 --> 00:07:16,450 we have given that C is more frequent then B hence we are sorting it like that. 75 00:07:16,700 --> 00:07:23,150 So when we pass the ID on, not find this sort of sorting the normal string in the alphabetical order, 76 00:07:23,300 --> 00:07:31,430 this sort method for forestalls the fine method on each string so that the line would find a Oresteia 77 00:07:31,480 --> 00:07:39,230 or not find B or find C, return the indexes respectively of each string position in the open string. 78 00:07:39,380 --> 00:07:45,860 The sort then uses these written indexes rather than the original ABC string before the items in this 79 00:07:46,130 --> 00:07:46,460 list. 80 00:07:46,780 --> 00:07:53,750 This is why A, B and C appears to be sorted as ECN B reflecting the order in which they appear in the 81 00:07:54,200 --> 00:07:54,520 line. 82 00:07:54,740 --> 00:07:59,600 OK, now let us continue our discussion of this in the next session. 83 00:07:59,630 --> 00:08:00,820 That's it from the session. 84 00:08:00,830 --> 00:08:01,670 Thank you very much.