1 00:00:00,280 --> 00:00:06,000 Coming on to comment on multiple assignment, not the GCT function we will write that will find the 2 00:00:06,020 --> 00:00:12,630 GCD of Columbus, but before you learn how to code it, let us look at a trick in Python or multiple 3 00:00:12,630 --> 00:00:15,600 assignment, a multiple assignment Rigolets. 4 00:00:15,600 --> 00:00:21,280 You assign values to more than one variable at once in a single assignment statement. 5 00:00:21,320 --> 00:00:30,720 Now, for example, if we enter something over here, 60 are common as are two is equal to 40 to Gamma 6 00:00:30,930 --> 00:00:31,980 in single codes. 7 00:00:31,990 --> 00:00:32,400 Hello. 8 00:00:32,670 --> 00:00:38,090 If we print SDR, we get 42 if we people start to get help. 9 00:00:38,490 --> 00:00:48,260 Suppose if we see A1 comma, B one, comma, C one or the one that's equal to here, we will see A, 10 00:00:48,360 --> 00:00:49,710 B, C anything. 11 00:00:50,400 --> 00:00:51,330 Then we give back. 12 00:00:51,330 --> 00:00:54,440 You are C SDC element. 13 00:00:54,900 --> 00:01:04,130 Now if we try to print A1, we get A, B, C and we get C, we could see one SDC and one is Elliman. 14 00:01:04,710 --> 00:01:05,100 Right. 15 00:01:05,340 --> 00:01:10,650 So in this particular approach, we can separate the variable names on the left side of the equal to 16 00:01:10,680 --> 00:01:15,150 operator, as well as the values on the right side of the equal to operator using comma. 17 00:01:15,660 --> 00:01:22,140 You can also assign each of the values in the list to its own variable as long as the number of items 18 00:01:22,140 --> 00:01:26,210 in the list is the same as number of variables on the left of equal to operator. 19 00:01:26,700 --> 00:01:33,360 If you don't have the same number of variables as you have values, Biton rule with an error that indicates 20 00:01:33,360 --> 00:01:36,300 the call needs more or has too many value. 21 00:01:36,750 --> 00:01:42,690 Now one of the main uses of this multiple assignment is to swap the values into variables. 22 00:01:43,020 --> 00:01:51,810 For example, if we try to enter something over here, since it is equal to say hello to is equal to 23 00:01:52,080 --> 00:01:53,860 C bitin. 24 00:01:54,210 --> 00:02:01,350 OK, now if we see SDR comma Estie are two is equal to values here. 25 00:02:01,350 --> 00:02:04,870 60 are comma SDR two or. 26 00:02:04,880 --> 00:02:05,110 Right. 27 00:02:05,170 --> 00:02:07,250 Let's give a start to an heuristic. 28 00:02:08,010 --> 00:02:13,290 Now we try to print Asgeir, we get Biton, we try to start to, we get help. 29 00:02:13,680 --> 00:02:20,670 So now after assigning hello to estab and fighting to a start, we have swapped those values using a 30 00:02:20,670 --> 00:02:21,780 multiple assignment. 31 00:02:22,150 --> 00:02:28,620 OK, now let us look at how this swapping trick would implement in your SO the Euclid's algorithm for 32 00:02:28,620 --> 00:02:35,430 finding the GC now coming to the Euclid's algorithm for finding the GCD now finding the DVD seems simple 33 00:02:35,430 --> 00:02:35,850 enough. 34 00:02:35,850 --> 00:02:41,490 Identify all the factors of Colombo's you will use and then find the largest factor they have in common. 35 00:02:41,820 --> 00:02:45,130 But it isn't so easy to find a GCG of larger numbers. 36 00:02:45,240 --> 00:02:51,600 So are Euclid, a mathematician who has basically come up with a short algorithm for finding a GCG of 37 00:02:51,600 --> 00:02:53,670 two numbers using a modular arithmetic? 38 00:02:54,060 --> 00:03:00,360 So Hels A. function that implements this algorithm in Biton, returning the GCG of individuals that 39 00:03:00,360 --> 00:03:01,450 we are passing it. 40 00:03:01,530 --> 00:03:08,670 So for example, suppose we write something like C, we will not say if this it is just for our demonstration. 41 00:03:08,670 --> 00:03:18,210 We say define GCD in brackets A, comma, B, and what we are defining say while a not equal to zero, 42 00:03:18,810 --> 00:03:30,000 here you are seeing a comma B equal to be divided or modulo a comma E and then we see the value of B, 43 00:03:30,900 --> 00:03:31,350 OK. 44 00:03:31,350 --> 00:03:39,090 Now in this GCT function it takes two numbers and B and then uses a loop and multiple assignment to 45 00:03:39,090 --> 00:03:45,750 find out exactly how the Euclid's algorithm Volke is beyond the scope of this particular session. 46 00:03:45,750 --> 00:03:50,190 But you can rely on this function to return the GCG of two individuals. 47 00:03:50,400 --> 00:03:56,580 You posit if you call this function from the interactive shell and posits it any number of parameters 48 00:03:56,580 --> 00:03:58,830 to and we will return a particular value. 49 00:03:59,340 --> 00:04:01,140 Now let us try and save this. 50 00:04:01,410 --> 00:04:11,310 We would save it in our intermediate level and let us give it a name C given by OK. 51 00:04:11,580 --> 00:04:18,840 And now if we go back here now after saving this, if we go back to Interactive Shell and if we see 52 00:04:19,350 --> 00:04:25,530 gcd see OK now we'll have to import it since they import gcd. 53 00:04:25,530 --> 00:04:30,480 One thought right now by what name have received it. 54 00:04:32,340 --> 00:04:35,310 It is G C D one B by. 55 00:04:35,310 --> 00:04:39,300 OK, but it has not found a module into it. 56 00:04:40,050 --> 00:04:47,040 So let us do one thing, let us define this directly over here, OK. 57 00:04:47,040 --> 00:04:54,930 And now we see GCD and some value say twenty four and thirty six or thirty two. 58 00:04:55,770 --> 00:04:58,710 So we get there the numbers eight. 59 00:04:59,780 --> 00:05:06,140 So over here, the great benefit of this is you can easily handle large numbers also, for example, 60 00:05:06,290 --> 00:05:13,820 if you want to handle some large numbers over here on the parameters, you will get the highest factorial. 61 00:05:13,940 --> 00:05:15,530 That is the highest common factor. 62 00:05:16,130 --> 00:05:23,100 OK, so this particular GCD function will come in handy when choosing the wallet keys for the multiplicative 63 00:05:23,100 --> 00:05:25,810 undefined cyphers, which you will learn in the next session. 64 00:05:25,850 --> 00:05:32,390 Now, coming to understanding how the multiplicative and defined Saiful Vokes now indices are Saiful 65 00:05:32,390 --> 00:05:37,670 encrypting and decrypting symbols involved, converting them to numbers, adding and subtracting the 66 00:05:37,670 --> 00:05:40,530 keys, and then converting the new number back to a symbol. 67 00:05:40,970 --> 00:05:45,970 So when encrypting with Multiplicative Saiful, you will multiply the index by the key. 68 00:05:46,310 --> 00:05:52,790 For example, if you interpret the letter E with the key three you will use is in the four and multiplied 69 00:05:52,790 --> 00:05:57,710 by the key three together index of the encrypted letter, which would be something like three four, 70 00:05:57,710 --> 00:06:02,480 one, two, three equals 12, which would be say when the product exceeds that an appropriate number 71 00:06:02,480 --> 00:06:03,140 of letters. 72 00:06:03,350 --> 00:06:09,170 The multiplicative cipher has a wraparound issue similar to the Caesar the cipher, but now it can use 73 00:06:09,170 --> 00:06:10,670 the more operator to solve. 74 00:06:10,670 --> 00:06:15,950 This, for example, uses a cipher symbol variable that we had was storing all the capital of those 75 00:06:15,950 --> 00:06:17,390 more letters and numbers. 76 00:06:17,750 --> 00:06:23,900 OK, now we can also use that to all the few characters of the symbol along with the indexes. 77 00:06:24,290 --> 00:06:28,570 And you can calculate what the symbols encrypt, what the key is, OK? 78 00:06:28,580 --> 00:06:35,540 And you can enter the particular symbols with the 17 multiplied in the Sify by 17 and the more the whole 79 00:06:35,540 --> 00:06:41,360 result by six to six to handle the wraparound of physics and blissett, and the result would be in 19. 80 00:06:41,360 --> 00:06:43,980 So 19 corresponds to the symbol, for example. 81 00:06:44,330 --> 00:06:46,160 In this way we can handle that. 82 00:06:46,520 --> 00:06:53,870 If we come to coming to the choosing a valid multiplicative keys, you can just use any number of multiplicative 83 00:06:53,870 --> 00:06:54,500 cipher keys. 84 00:06:54,500 --> 00:07:00,080 For example, if you choose eleven can have a mapping, you would end up with some different values 85 00:07:00,080 --> 00:07:06,590 that now notice that this particular key doesn't work because symbol and all entry to the same letter 86 00:07:06,590 --> 00:07:06,860 eight. 87 00:07:07,280 --> 00:07:11,800 So when you encounter an aim, the ciphertext, you wouldn't know what symbol decrypts. 88 00:07:12,320 --> 00:07:18,940 So using this key would basically run into some problem and flipping letters like A.F. and afficionados 89 00:07:19,340 --> 00:07:25,850 now in a multiplicative cipher, the key and the size of the symbols, it must be relatively prime to 90 00:07:25,850 --> 00:07:26,370 each other. 91 00:07:26,720 --> 00:07:30,530 Now two numbers are relatively prime or cooperating with the kids. 92 00:07:30,530 --> 00:07:30,800 One. 93 00:07:31,130 --> 00:07:34,810 So in other words, they have no factors in common except one. 94 00:07:34,820 --> 00:07:41,840 For example, the numbers and one and two, a relatively prime if GC and one comma and two is equal 95 00:07:41,840 --> 00:07:42,620 to one well. 96 00:07:42,650 --> 00:07:45,530 And one is the key and with the size of the symbol. 97 00:07:46,370 --> 00:07:52,640 OK, so as in the older example, because 11 and six to six, how would you say that is in the one they 98 00:07:52,640 --> 00:07:57,950 are not relatively prime, which means that Key 11 cannot be used for the multiple cipher. 99 00:07:58,280 --> 00:08:04,050 Not that the numbers don't actually have to be prime numbers to be relatively prime to each other. 100 00:08:04,430 --> 00:08:10,790 So knowing how to use a modular arithmetic and the G function is important when using a multiplicative 101 00:08:10,790 --> 00:08:16,610 cipher, you can use the GCT function to figure out whether a pair of numbers is relatively prime, 102 00:08:16,940 --> 00:08:20,510 which you need to know to choose a valid for multiplicative Saiful. 103 00:08:20,990 --> 00:08:26,220 OK, so a multiplicative cipher has only 20 different keys for a set of six to six symbols. 104 00:08:26,480 --> 00:08:28,200 Even fewer than this is a site. 105 00:08:28,660 --> 00:08:34,790 However, you can combine the multiplicative cipher and Caesar to get a more powerful afine cipher, 106 00:08:35,120 --> 00:08:37,310 which we will be discussing later.