Coming on to comment on multiple assignment, not the GCT function we will write that will find the
GCD of Columbus, but before you learn how to code it, let us look at a trick in Python or multiple
assignment, a multiple assignment Rigolets.
You assign values to more than one variable at once in a single assignment statement.
Now, for example, if we enter something over here, 60 are common as are two is equal to 40 to Gamma
in single codes.
Hello.
If we print SDR, we get 42 if we people start to get help.
Suppose if we see A1 comma, B one, comma, C one or the one that's equal to here, we will see A,
B, C anything.
Then we give back.
You are C SDC element.
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.
Right.
So in this particular approach, we can separate the variable names on the left side of the equal to
operator, as well as the values on the right side of the equal to operator using comma.
You can also assign each of the values in the list to its own variable as long as the number of items
in the list is the same as number of variables on the left of equal to operator.
If you don't have the same number of variables as you have values, Biton rule with an error that indicates
the call needs more or has too many value.
Now one of the main uses of this multiple assignment is to swap the values into variables.
For example, if we try to enter something over here, since it is equal to say hello to is equal to
C bitin.
OK, now if we see SDR comma Estie are two is equal to values here.
60 are comma SDR two or.
Right.
Let's give a start to an heuristic.
Now we try to print Asgeir, we get Biton, we try to start to, we get help.
So now after assigning hello to estab and fighting to a start, we have swapped those values using a
multiple assignment.
OK, now let us look at how this swapping trick would implement in your SO the Euclid's algorithm for
finding the GC now coming to the Euclid's algorithm for finding the GCD now finding the DVD seems simple
enough.
Identify all the factors of Colombo's you will use and then find the largest factor they have in common.
But it isn't so easy to find a GCG of larger numbers.
So are Euclid, a mathematician who has basically come up with a short algorithm for finding a GCG of
two numbers using a modular arithmetic?
So Hels A. function that implements this algorithm in Biton, returning the GCG of individuals that
we are passing it.
So for example, suppose we write something like C, we will not say if this it is just for our demonstration.
We say define GCD in brackets A, comma, B, and what we are defining say while a not equal to zero,
here you are seeing a comma B equal to be divided or modulo a comma E and then we see the value of B,
OK.
Now in this GCT function it takes two numbers and B and then uses a loop and multiple assignment to
find out exactly how the Euclid's algorithm Volke is beyond the scope of this particular session.
But you can rely on this function to return the GCG of two individuals.
You posit if you call this function from the interactive shell and posits it any number of parameters
to and we will return a particular value.
Now let us try and save this.
We would save it in our intermediate level and let us give it a name C given by OK.
And now if we go back here now after saving this, if we go back to Interactive Shell and if we see
gcd see OK now we'll have to import it since they import gcd.
One thought right now by what name have received it.
It is G C D one B by.
OK, but it has not found a module into it.
So let us do one thing, let us define this directly over here, OK.
And now we see GCD and some value say twenty four and thirty six or thirty two.
So we get there the numbers eight.
So over here, the great benefit of this is you can easily handle large numbers also, for example,
if you want to handle some large numbers over here on the parameters, you will get the highest factorial.
That is the highest common factor.
OK, so this particular GCD function will come in handy when choosing the wallet keys for the multiplicative
undefined cyphers, which you will learn in the next session.
Now, coming to understanding how the multiplicative and defined Saiful Vokes now indices are Saiful
encrypting and decrypting symbols involved, converting them to numbers, adding and subtracting the
keys, and then converting the new number back to a symbol.
So when encrypting with Multiplicative Saiful, you will multiply the index by the key.
For example, if you interpret the letter E with the key three you will use is in the four and multiplied
by the key three together index of the encrypted letter, which would be something like three four,
one, two, three equals 12, which would be say when the product exceeds that an appropriate number
of letters.
The multiplicative cipher has a wraparound issue similar to the Caesar the cipher, but now it can use
the more operator to solve.
This, for example, uses a cipher symbol variable that we had was storing all the capital of those
more letters and numbers.
OK, now we can also use that to all the few characters of the symbol along with the indexes.
And you can calculate what the symbols encrypt, what the key is, OK?
And you can enter the particular symbols with the 17 multiplied in the Sify by 17 and the more the whole
result by six to six to handle the wraparound of physics and blissett, and the result would be in 19.
So 19 corresponds to the symbol, for example.
In this way we can handle that.
If we come to coming to the choosing a valid multiplicative keys, you can just use any number of multiplicative
cipher keys.
For example, if you choose eleven can have a mapping, you would end up with some different values
that now notice that this particular key doesn't work because symbol and all entry to the same letter
eight.
So when you encounter an aim, the ciphertext, you wouldn't know what symbol decrypts.
So using this key would basically run into some problem and flipping letters like A.F. and afficionados
now in a multiplicative cipher, the key and the size of the symbols, it must be relatively prime to
each other.
Now two numbers are relatively prime or cooperating with the kids.
One.
So in other words, they have no factors in common except one.
For example, the numbers and one and two, a relatively prime if GC and one comma and two is equal
to one well.
And one is the key and with the size of the symbol.
OK, so as in the older example, because 11 and six to six, how would you say that is in the one they
are not relatively prime, which means that Key 11 cannot be used for the multiple cipher.
Not that the numbers don't actually have to be prime numbers to be relatively prime to each other.
So knowing how to use a modular arithmetic and the G function is important when using a multiplicative
cipher, you can use the GCT function to figure out whether a pair of numbers is relatively prime,
which you need to know to choose a valid for multiplicative Saiful.
OK, so a multiplicative cipher has only 20 different keys for a set of six to six symbols.
Even fewer than this is a site.
However, you can combine the multiplicative cipher and Caesar to get a more powerful afine cipher,
which we will be discussing later.