WEBVTT

00:01.050 --> 00:02.790
So let's solve the next question.

00:03.420 --> 00:11.370
It is regarding a Caesar cipher is a simple substitution cipher in which each letter of the plaintext

00:11.670 --> 00:16.290
is substituted with a letter found by moving in places down the alphabet.

00:16.830 --> 00:22.320
So, for example, let's assume the input plain text as B, C, D, X, Y or Z.

00:22.650 --> 00:25.740
So we've shifted by invisible to food.

00:26.100 --> 00:32.490
Let's see what you find is equal before then will be changed to e b will be changed to f, c will be

00:32.490 --> 00:33.360
changed to G.

00:33.630 --> 00:35.040
They will be changed to H.

00:35.160 --> 00:35.790
I'm sure.

00:36.660 --> 00:40.260
And you'll excuse me change to be y to see that 2D.

00:41.100 --> 00:45.780
So here and will be the value which will be provided separately.

00:46.600 --> 00:47.970
I think so.

00:47.970 --> 00:52.230
I guess here is to write a function that accepts the argument.

00:52.260 --> 00:59.340
One is the text, which is something like this, and another value, a number by which the letters need

00:59.340 --> 01:00.110
to be shifted.

01:00.150 --> 01:01.350
That is in here.

01:02.340 --> 01:05.610
Now, this function will return an encrypted string.

01:05.850 --> 01:12.450
Will all the letters transform from this form to this function, while all the punctuations and white

01:12.450 --> 01:14.340
spaces will remain unchanged?

01:15.270 --> 01:16.680
So try this out.

01:17.190 --> 01:22.920
And you can pause the video now and unpause in case you want to see the solution for them.

01:33.720 --> 01:36.030
Now, let's go ahead and that's why I've been in problem.

01:37.170 --> 01:39.580
So this is a string related problems.

01:39.580 --> 01:43.320
So for this, we will need to import those drinks library.

01:43.650 --> 01:51.000
So let's say import strength as s d.

01:52.650 --> 02:07.410
I am strength or let me make this next in String's Library, we already have letters which are already

02:07.410 --> 02:13.800
present in lowercase and a book bookcase fought so we can download the ones, so we can simply say letters

02:14.910 --> 02:15.540
is equal.

02:15.550 --> 02:23.880
Those green dot sky underscored lowercase.

02:25.980 --> 02:27.810
Let's see, what do we have in letters?

02:28.980 --> 02:32.370
So here we have all the letters in lowercase.

02:33.510 --> 02:37.060
Now let's get the number in.

02:37.080 --> 02:40.960
So let's get the number in as an input now.

02:40.980 --> 02:42.470
And we're getting it as an input.

02:42.480 --> 02:44.460
We need to convert it into integer also.

02:44.460 --> 02:45.360
So we say in

02:48.660 --> 02:57.150
input and insight input, we say how many shifts?

03:01.690 --> 03:04.150
And the person can enter the number of ships they want.

03:06.170 --> 03:08.590
Now we need to shift.

03:08.620 --> 03:09.880
Each and every year.

03:10.150 --> 03:15.160
So let's try to create something as shifted here.

03:15.160 --> 03:18.190
So we create another list with shifting regulators.

03:18.550 --> 03:19.450
So let's see.

03:19.460 --> 03:25.840
Shifted and shifted will be equal to now.

03:25.840 --> 03:27.480
What will we have in shifted?

03:27.490 --> 03:31.150
So inch of third, we will have a BKD.

03:31.240 --> 03:36.010
So let's say there are a number of the number of letters which we have shifted by four.

03:36.580 --> 03:38.410
So when we shift by four.

03:42.990 --> 03:51.300
Then we show these by fall, we will have these letters, as it does, but they will be shifted in the

03:51.300 --> 03:51.630
list.

03:51.900 --> 03:54.450
So the index will be a little different.

03:54.990 --> 04:00.750
So what can we do is we can create the list by letters and in letters.

04:00.750 --> 04:06.770
We will get only the values which will be having, let's say, shifted by.

04:06.780 --> 04:12.810
And so we can simply say we want the letters to start from in and hope delivery.

04:14.310 --> 04:15.390
What do we get here?

04:15.540 --> 04:18.540
Let's shift it and let's practice.

04:19.230 --> 04:20.340
So let's step four.

04:21.310 --> 04:25.020
So it gives me these shuffled ones.

04:25.410 --> 04:28.200
Now then we try to map these.

04:28.470 --> 04:33.150
So Z will be mapping of some other character.

04:33.390 --> 04:36.810
But the last few characters are still missing their mappings.

04:38.070 --> 04:40.770
So for that or let me print it for you.

04:41.250 --> 04:50.330
Let's print that for, you know, let's say four.

04:51.600 --> 04:55.560
So you can see this one is shorter than this one.

04:57.660 --> 05:00.510
So what if we have F E for B?

05:00.510 --> 05:02.700
We have F for C, we have T.

05:03.060 --> 05:06.990
But we do not have anything for WXYZ.

05:07.110 --> 05:16.980
So for that, we need to add these characters in the at the end so we can do that by simply adding letters

05:17.910 --> 05:20.790
from the very beginning, still in in time.

05:21.870 --> 05:22.680
So let's see.

05:22.680 --> 05:23.370
What do we get?

05:24.360 --> 05:25.200
That's a fourth.

05:25.950 --> 05:29.140
So here you can see this is this mapping which we have got.

05:29.160 --> 05:31.110
This is the mapping which we have generated.

05:31.500 --> 05:35.970
So when we say for ship, it will replace this by this, this by this.

05:36.240 --> 05:41.490
Now, below, we have created what the sequence should be, but we have still not told that whenever

05:41.490 --> 05:44.790
you find a replaceability, that is still not been done.

05:45.270 --> 05:49.820
So for that, actually, we have to create a map function.

05:49.830 --> 05:54.320
So what the mapper does is it will basically map those values to each other.

05:54.330 --> 05:56.250
So let's create the map of function here.

05:57.780 --> 06:02.300
So we say map book equals.

06:02.940 --> 06:03.930
It's a dictionary.

06:04.410 --> 06:06.840
So we are creating a dictionary in the dictionary.

06:06.840 --> 06:07.440
What do we have?

06:07.440 --> 06:08.490
We have letters.

06:09.420 --> 06:11.610
And in the letters, we take index.

06:13.800 --> 06:19.320
And with it, we say shifted and index.

06:19.350 --> 06:31.600
I for I in range of all letters.

06:32.370 --> 06:35.250
What it simply does is its print map.

06:37.950 --> 06:42.420
So for each and every character, you have created a mapping.

06:44.130 --> 06:49.250
Right now, what we need to do further is let's say we have any text, OK?

06:49.260 --> 06:56.970
Let's say we have a text is going to do this.

06:57.660 --> 06:58.620
Before the

07:01.140 --> 07:04.890
door was saying, OK,

07:07.860 --> 07:09.700
this is a decent sentence.

07:09.720 --> 07:16.710
Now, if you want to transform it, we can simply say so here we get each and every alphabet.

07:17.220 --> 07:20.340
Now, I want to get alphabet from the map itself.

07:20.790 --> 07:25.500
So I will t or let's get the alphabet one by one.

07:25.800 --> 07:28.050
Now, if the map is present.

07:35.400 --> 07:39.300
In my book, Dark Keys.

07:41.500 --> 07:46.690
Then it should return my bush.

07:49.700 --> 08:00.980
It's like if it is not present, is it should simply read-only as hazardous.

08:03.420 --> 08:09.390
So this is what we have now, this still needs to be converted into a sentence full so we can simply

08:09.390 --> 08:09.720
say

08:13.200 --> 08:17.870
not join join me to break it.

08:19.560 --> 08:20.550
So let's run this.

08:21.270 --> 08:25.590
So what it simply did is it converted it and joined.

08:25.740 --> 08:26.610
What have we done?

08:26.910 --> 08:32.760
We have simply created a map, but then we have created a dictionary, kind of all of what needs to

08:32.820 --> 08:33.990
be converted to what.

08:34.440 --> 08:39.630
Then we check if the character which we are looking for is present in the map or the keys.

08:40.020 --> 08:41.910
Then we simply put the map.

08:41.910 --> 08:45.180
But here, if it is not there, then we put the alphabet.

08:45.600 --> 08:51.510
So wherever we have these exclamation marks or those pieces, they will be one thing as it is.

08:51.720 --> 08:57.960
Otherwise, it will try to insert the map or key that because it will try to insert the value of the

08:57.960 --> 08:58.170
map.

09:00.000 --> 09:00.510
That's it.

09:00.750 --> 09:03.120
So this is how we solve this particular problem.

09:04.200 --> 09:07.890
And then you can convert it into a function or anything you want.

09:08.430 --> 09:10.990
So that is something which you can do on top of this.
