1 00:00:00,210 --> 00:00:05,160 Coming to the joint string method that we have used over here in the written statement. 2 00:00:05,400 --> 00:00:11,660 Now, this basically is help to or do a joint of individual column strings into the 054 takes us into 3 00:00:11,670 --> 00:00:12,270 one string. 4 00:00:12,630 --> 00:00:17,820 So the joint method is basically called on a string value and takes a list of strings. 5 00:00:18,010 --> 00:00:25,350 It returns one string that has all the members in the list, joined by the string that join method is 6 00:00:25,350 --> 00:00:25,980 called on. 7 00:00:26,820 --> 00:00:32,160 For example, if you want to try it in the interactive shell, let's go back to Titan here and here. 8 00:00:32,160 --> 00:00:35,000 Recreate, say, for example, L1. 9 00:00:35,010 --> 00:00:35,970 That's equal to. 10 00:00:36,750 --> 00:00:39,730 Let's give some different text there. 11 00:00:41,910 --> 00:00:47,700 And here we see a single dot dot joint. 12 00:00:49,120 --> 00:00:59,400 Eleven, so we have added that value there, a black value to it, similarly, if we see the joint LVA, 13 00:00:59,890 --> 00:01:11,500 so we get a comma for every value that we have there, or if we see capital ABC DOT join LVA, we get 14 00:01:11,500 --> 00:01:14,350 ABC added to every value in the particular string. 15 00:01:14,650 --> 00:01:21,400 So when you call the joint on an empty string and join the list that is Elvan, you get the list of 16 00:01:21,400 --> 00:01:25,000 list strings concatenated with no string in between. 17 00:01:25,390 --> 00:01:31,720 So in some cases you might want to separate each member in the list to make it more readable, which 18 00:01:31,720 --> 00:01:38,200 we have done when we say join on calling the string in a comma, that's insert a string comma between 19 00:01:38,200 --> 00:01:39,700 each member of the list. 20 00:01:39,930 --> 00:01:44,830 You can also insert any string you want between the list members, as we have done in the last. 21 00:01:45,140 --> 00:01:48,570 OK, now coming to the return values and the written statement. 22 00:01:49,300 --> 00:01:57,190 So let's go back to our goal here and only function or the function call always evaluates to a particular 23 00:01:57,190 --> 00:01:57,590 value. 24 00:01:58,180 --> 00:02:01,060 So this is the value written by the function of the method. 25 00:02:01,300 --> 00:02:08,530 So also called the return value of the function of when you create your own function using the def statement, 26 00:02:08,530 --> 00:02:15,130 a written statement, this python Waterton value for the function is like over here we have total return 27 00:02:15,430 --> 00:02:18,910 in single code dot joint and this ciphertext Istria. 28 00:02:19,210 --> 00:02:24,130 So here we call joint on the blank string and passes ciphertext as the argument. 29 00:02:24,150 --> 00:02:31,270 So the string in the ciphertext SDR list are joining the single string coming to a written statement 30 00:02:31,270 --> 00:02:31,830 example. 31 00:02:31,840 --> 00:02:37,270 Now a written statement is basically a written word, followed by the value to be written so you can 32 00:02:37,270 --> 00:02:40,480 use an expression instead of a value like when you do. 33 00:02:40,480 --> 00:02:43,480 So, the return value is whatever that expression evaluates. 34 00:02:43,480 --> 00:02:43,740 True. 35 00:02:44,080 --> 00:02:55,300 For example, let us create a new file and we would say here a definition for add numbers, say a comma 36 00:02:55,300 --> 00:03:07,090 C, and here we are going to see written A plus C and we would say here, print in bracket C, add numbers. 37 00:03:07,420 --> 00:03:11,140 We give your say three comma 50 as the parameter. 38 00:03:11,650 --> 00:03:19,530 Let's see if this as normal 12 thought by and let us execute this so we get the values. 39 00:03:19,540 --> 00:03:22,480 Fifty three when the program is executed. 40 00:03:22,690 --> 00:03:29,560 Now that is because the function calls or add numbers because the three and four feet as the value and 41 00:03:29,560 --> 00:03:34,720 evaluates to fifty three and the written statement in the function that we have created. 42 00:03:34,960 --> 00:03:41,470 Add the second line, evaluates the expression A plus C and returns the evaluated value to the calling 43 00:03:41,470 --> 00:03:41,880 program. 44 00:03:42,310 --> 00:03:42,650 Right. 45 00:03:42,760 --> 00:03:47,150 Similarly, we have the returning of the encrypted text in our demo. 46 00:03:47,470 --> 00:03:53,080 So like in this case over here, we are returning the value back when we are actually calling the particular 47 00:03:53,350 --> 00:03:53,800 program. 48 00:03:54,430 --> 00:03:59,950 So in this, the encrypt messages still function, returns the statement that returns a string value 49 00:03:59,950 --> 00:04:05,070 that is created by joining all of these strings in the ciphertext list. 50 00:04:05,650 --> 00:04:11,350 And this final string, the result of the encryption code is retained by our encrypt messages to our 51 00:04:11,350 --> 00:04:11,830 function. 52 00:04:12,190 --> 00:04:18,580 Now, a great advantage of using functions is that a programmer has to know what the function does, 53 00:04:18,790 --> 00:04:21,820 but doesn't need to know how the function scorebook. 54 00:04:22,120 --> 00:04:27,790 A programmer can understand that when they call a particular function and pass it an integer as well 55 00:04:27,790 --> 00:04:33,250 as a string for the key and the message parameters function call evaluates to an encrypted string. 56 00:04:33,580 --> 00:04:39,670 They don't need to know anything about how the code is encrypted, actually, which is similar to know 57 00:04:39,940 --> 00:04:46,120 that you pass a particular string to the print message in the particular given string back to the function 58 00:04:46,150 --> 00:04:52,450 for now coming to the underscore variable like we have used here in the IF. 59 00:04:52,450 --> 00:04:59,650 But now you can don the given transposition encryption program into a module using a special trick involving 60 00:04:59,650 --> 00:05:03,890 the main function and the variable named the underscore name. 61 00:05:04,700 --> 00:05:10,000 Now when you run a Python program, that's to underscore before they went to one of the schools after 62 00:05:10,000 --> 00:05:16,990 name that we have used here is assigned the string mean even before the first line of the program runs 63 00:05:16,990 --> 00:05:23,850 the double and the score is often referred to as the under in Python and double the score mean double. 64 00:05:23,860 --> 00:05:26,170 And the school is called the under the under. 65 00:05:26,560 --> 00:05:33,160 At the end of the script you want to have some code that checks whether the name variable has mean string 66 00:05:33,160 --> 00:05:33,910 assigned to it. 67 00:05:34,210 --> 00:05:39,940 If so, you want to call the main function the if statement over here that we have used the second last 68 00:05:39,940 --> 00:05:40,300 line. 69 00:05:41,290 --> 00:05:46,870 Actually is one of the first line of the code which is executed when you run the particular program. 70 00:05:47,260 --> 00:05:53,550 So when you run this basically first check if name is equal to mean and it'll call the main function. 71 00:05:53,860 --> 00:06:00,100 The reason the machine is set up over here this way is that although Python is said name to mean when 72 00:06:00,100 --> 00:06:05,500 the program is run, it sets it to the string transposition of the file the mountain over here, if 73 00:06:05,500 --> 00:06:11,860 the program is imported by another program or another python program, we can see similarly to how the 74 00:06:11,860 --> 00:06:15,340 program imposes a paperclip module to call the function in it. 75 00:06:15,670 --> 00:06:22,030 So other programs might want to import the same program to call it encrypt messages still function without 76 00:06:22,030 --> 00:06:23,200 the main function running. 77 00:06:23,470 --> 00:06:29,670 So when an import statement is executed, Python looks for particular modules file by adding a dot prior 78 00:06:29,680 --> 00:06:30,700 to the end of the file. 79 00:06:31,240 --> 00:06:37,150 So this is how our program knows whether it's being run as a main program or importer by a different 80 00:06:37,150 --> 00:06:39,010 program as a module. 81 00:06:39,220 --> 00:06:46,010 So if you import a Python program and before the program is executed, the name variable is set to define 82 00:06:46,010 --> 00:06:47,920 the import before dot be right. 83 00:06:48,460 --> 00:06:50,350 For example, here it is. 84 00:06:50,350 --> 00:06:54,760 The more tentative program is imported and all the def statements are run. 85 00:06:55,120 --> 00:06:56,940 But the main function is the call. 86 00:06:57,190 --> 00:07:03,730 So the encryption code for that we have that python hacking code message with the key of it will not 87 00:07:03,730 --> 00:07:04,560 be executed. 88 00:07:04,900 --> 00:07:11,590 So that is why the code that encrypts the my message is to string with the mixture is inside a particular 89 00:07:11,590 --> 00:07:15,280 function and this code inside mean we won't run. 90 00:07:15,280 --> 00:07:20,620 Your actual name would then not be via program, which is imported by another program. 91 00:07:20,800 --> 00:07:25,000 But these other programs can still call the encrypt messages still function. 92 00:07:25,210 --> 00:07:26,560 That is how they functions. 93 00:07:26,560 --> 00:07:30,240 School can be reused by other bitin programming. 94 00:07:30,250 --> 00:07:31,330 That is right. 95 00:07:31,660 --> 00:07:39,550 So in this way, we have seen our whole demonstration actually doing it manually also, and then doing 96 00:07:39,550 --> 00:07:45,850 the same goal in the Python program also, which has made up a concept of how actually the transposition 97 00:07:45,850 --> 00:07:47,620 cipher looks very much clear. 98 00:07:48,010 --> 00:07:48,300 Right. 99 00:07:48,520 --> 00:07:51,000 So that's it from the session. 100 00:07:51,010 --> 00:07:51,970 Thank you very much.