WEBVTT

00:00.990 --> 00:03.930
Next hour, a few questions with the string operations.

00:04.320 --> 00:12.150
So here we have a problem where you want to change keys to location, location to upper case, and a

00:12.150 --> 00:18.600
problem where you have to do all the string modifications to create this.

00:18.600 --> 00:21.810
Turn this into a simple, understandable sentence.

00:22.530 --> 00:29.790
And the third one is where you need to identify the numbers from the string and then find the average

00:29.790 --> 00:33.090
and some of those numbers ignoring all the characters.

00:33.810 --> 00:35.040
So you can pull boards.

00:35.040 --> 00:37.440
Do we do now and then solve the questions?

00:37.680 --> 00:41.670
I will be explaining the solutions after a few seconds.

00:53.660 --> 00:55.850
I hope you would have solved these questions.

00:56.150 --> 01:00.440
So now let's have a look at the solutions for the scene.

01:00.920 --> 01:08.600
The first question is where we need to find out the conversion of operatives to lower keys and lower

01:08.600 --> 01:09.650
keys to a bucket.

01:10.130 --> 01:18.770
If I would have been a new fortune to Vitan, I would have identified by searching through the entire

01:19.160 --> 01:24.480
list of characters here, I would have gone to all these fringe characters and checked.

01:24.860 --> 01:32.510
If these characters were screened and then converted the uppercase lowercase and then lowercase two

01:32.510 --> 01:33.110
of the piece.

01:33.560 --> 01:40.670
But this is a very simple question, because Python already provides a function which allows you to

01:40.670 --> 01:45.860
convert and to swap the cases so we can directly use that function.

01:46.100 --> 01:48.250
So I can simply say print

01:51.110 --> 01:51.440
string.

01:51.650 --> 01:53.140
Don't swap it.

01:53.540 --> 02:02.180
So we have string dot swap keys and we simply run the function.

02:03.590 --> 02:11.420
And here you can see we have converted all the uppercase to law cases and all the normal cases to other

02:11.420 --> 02:13.100
cases, as simple as that.

02:13.160 --> 02:14.210
Nothing complicated.

02:15.320 --> 02:18.680
Next, we have this particular sentence here.

02:18.920 --> 02:22.460
Now, you can see there are a lot of problems with these sentences.

02:22.730 --> 02:28.180
First is that you can read the sentence also that police losi are typing.

02:28.190 --> 02:32.960
She has used special characters in place of spaces, sometimes added.

02:33.230 --> 02:36.030
She does not even care about tendance cases.

02:36.050 --> 02:38.900
Can you please help us connect this text?

02:39.440 --> 02:44.960
So here you can see she has used a lot of special characters at different places.

02:46.310 --> 02:52.250
And these are special characters are used in place of space.

02:53.630 --> 02:56.900
So we need to handle all these one by one.

02:59.660 --> 03:04.370
So let's simply get the print of this.

03:06.980 --> 03:09.880
And we want to obtain different words from this.

03:09.880 --> 03:12.230
So we see text.

03:13.980 --> 03:23.420
From the floor, thanks in text.

03:24.660 --> 03:31.650
Now, if we do it this way, so it will try to get each character out of it, but we don't want to get

03:31.650 --> 03:33.000
it does we want votes.

03:33.390 --> 03:34.560
So we split it

03:39.420 --> 03:41.640
on the special accountability we are looking for.

03:41.640 --> 03:43.080
So we split it on hash.

03:43.950 --> 03:46.110
Now we need to convert this into a list as well.

03:49.490 --> 03:50.320
Let's get the result.

03:50.690 --> 03:57.380
So here you can see that these words have been split up into different words.

03:58.040 --> 04:00.770
Now we want to join this.

04:00.980 --> 04:05.810
We want to join these back together so that we can go ahead with the next function.

04:06.050 --> 04:08.210
So instead of this, let's simply say.

04:11.140 --> 04:18.820
Space don't join and inside join.

04:22.960 --> 04:23.710
We give.

04:31.970 --> 04:37.040
Now we have this now similarly, we want to split on Aderet and get this together.

04:37.520 --> 04:38.810
So we simply say

04:44.480 --> 04:46.130
don't join.

04:54.160 --> 04:54.700
These.

05:00.280 --> 05:02.990
And you want to join these after splitting it.

05:03.640 --> 05:05.620
So this was my first one.

05:10.800 --> 05:14.340
Make sure that you have all the jackets in place.

05:14.870 --> 05:16.170
So no, I slipped it

05:19.410 --> 05:20.400
on Anthony

05:23.550 --> 05:24.240
and then.

05:28.470 --> 05:30.390
Let's again check the brackets here.

05:32.130 --> 05:33.410
This is for Brent.

05:37.140 --> 05:39.000
Now, the Tascam minded on this.

05:39.660 --> 05:42.940
Now, again, I want to do it one more time.

05:42.960 --> 05:44.550
I have done it for hash.

05:44.550 --> 05:46.080
I have done it for this.

05:46.440 --> 05:49.170
Now let's capitalize these.

05:50.670 --> 05:54.480
So I will simply say,

05:57.390 --> 05:57.870
Don.

06:08.860 --> 06:11.500
So here is your correct sentence.

06:12.220 --> 06:17.560
I have done this all together in one single line of code.

06:17.890 --> 06:20.980
You can split this phone into multiple steps.

06:21.280 --> 06:27.130
You can use different operations instead of using what what I have used as solutions can be different.

06:28.090 --> 06:30.730
But this is just one of the solutions which you can track.

06:32.440 --> 06:35.620
Next question is we have this particular stream.

06:35.620 --> 06:41.200
We want to retrieve all the numbers from the string, and then we want to find the average in some of

06:41.200 --> 06:41.710
the numbers.

06:42.070 --> 06:48.430
Now, because I have this string, I have a function called is numeric, which allows me to find out

06:48.700 --> 06:52.120
if a particular character in the string is a number or not.

06:54.880 --> 06:57.380
So let's get each and every character out of there.

06:57.430 --> 07:03.430
So let's see if we were to let's create a list.

07:03.790 --> 07:12.700
So we say X four kicks in a little strange.

07:16.690 --> 07:18.400
So it gives me all the characters.

07:18.700 --> 07:25.210
Now I want to get the characters, which are only numeric so I can simply apply if condition here.

07:25.210 --> 07:30.970
So I see if x dot is numeric.

07:32.620 --> 07:39.040
This will check if a character is numeric and then it will return that guy like this.

07:39.700 --> 07:42.730
Now I have all the characters presentencing.

07:43.060 --> 07:45.040
And I can simply get these.

07:45.040 --> 07:45.850
I'm playing these.

07:45.850 --> 07:47.050
I'm an average of these.

07:47.530 --> 07:52.180
So let's find these some making him simple.

07:52.180 --> 07:53.260
Use the function some.

07:54.190 --> 07:57.690
We're finding this one now for finding the average.

07:57.700 --> 08:07.450
I can use the formula that is sum divided by the length of the characters or the number of occurrences.

08:07.780 --> 08:14.350
So I can simply say length of these, which gives me how many number of characters numbers I have.

08:14.800 --> 08:16.930
So this is what we get.

08:17.410 --> 08:27.130
Now, if you can see, this says unsupported operand, which is an integer.

08:27.340 --> 08:30.490
So it is still considering X2, B and string.

08:30.730 --> 08:32.710
So I need to convert this into an integer.

08:32.720 --> 08:33.880
So I say eight.

08:37.750 --> 08:39.610
And will we get the answer?

08:41.650 --> 08:46.580
So I hope you got this correct in case these were not correct for you.

08:46.600 --> 08:49.060
You will be waiting for them in these questions.

08:49.060 --> 08:50.710
You can keep on practicing.

08:50.710 --> 08:54.580
And over the time, you'll have an expertise on these.
