WEBVTT

00:00.670 --> 00:05.020
In some situations you will want to use a variable's value inside a string.

00:05.050 --> 00:11.260
For example, you might want to use two variables to represent the first name and the last name respectively,

00:11.260 --> 00:16.870
and then combine those values to display someone's well, full name.

00:16.870 --> 00:20.830
So here we will write first name.

00:21.130 --> 00:22.990
Or actually, let's instead of Y.

00:23.020 --> 00:26.320
Let's make manipulations on Oxford Academy's string.

00:26.320 --> 00:27.190
So.

00:29.300 --> 00:30.530
Let's make the.

00:32.150 --> 00:33.140
First name.

00:33.590 --> 00:34.580
First name.

00:35.720 --> 00:38.360
First name here, it's Oxley.

00:38.360 --> 00:42.980
And here last name is Academy.

00:43.100 --> 00:47.480
So now we will we will write full name.

00:48.170 --> 00:49.310
It's going to be.

00:50.430 --> 00:51.090
Here.

00:51.210 --> 00:53.400
F here.

00:53.460 --> 00:54.480
First name.

00:55.650 --> 00:57.780
And last name.

00:59.120 --> 01:02.060
And after that we will print the full name.

01:04.530 --> 01:08.040
Let's increase the text size a little bit so you can see it better.

01:10.540 --> 01:11.620
A thanks.

01:12.100 --> 01:14.380
Let's make the text size 33.

01:16.100 --> 01:17.150
That's perfect.

01:19.240 --> 01:25.660
So here to insert a variable's value into a string.

01:25.690 --> 01:26.000
Oops.

01:26.800 --> 01:32.260
Insert variable's value into a string place the letter F.

01:32.500 --> 01:33.130
Sorry.

01:33.280 --> 01:36.460
Here, place the letter F.

01:37.230 --> 01:42.540
Immediately before opening a quotation mark here.

01:44.260 --> 01:44.590
What?

01:44.590 --> 01:46.390
Braces a random name.

01:47.490 --> 01:48.330
Like this.

01:49.120 --> 01:50.860
But prices around the name.

01:53.380 --> 01:57.700
Or names of any variable you want to use inside the string.

01:57.700 --> 02:05.740
So Python will replicate or replace each variable with its value when the string is displayed.

02:05.740 --> 02:11.020
In this case, it's going to be Oxley and then Academy in the full name.

02:12.330 --> 02:14.160
So the strings are called.

02:14.210 --> 02:18.780
These strings are called F strings here F.

02:20.250 --> 02:21.120
Strings.

02:24.010 --> 02:27.250
F strings and the F here.

02:27.280 --> 02:30.490
The F here is for format.

02:31.560 --> 02:32.250
Format.

02:34.670 --> 02:41.720
Because Python formats the strings by replacing the name of any variable in braces with its value.

02:42.140 --> 02:44.450
So the output here, let's run this here.

02:44.450 --> 02:48.680
Let's print the full name and clear the screen for now.

02:48.680 --> 02:50.690
Now let's run the name here.

02:50.690 --> 02:56.870
And as you can see here, we got the Oxley and Academy in same string.

02:56.870 --> 02:59.300
So you can do a lot with F strings.

02:59.300 --> 03:06.500
For example, you can use F strings to compose complete message using the information associated with

03:06.500 --> 03:08.210
the variables.

03:08.210 --> 03:10.370
So now let's try this.

03:11.130 --> 03:12.420
Now instead of.

03:13.040 --> 03:15.590
And yes, inside print.

03:16.370 --> 03:18.020
Feel that print.

03:18.330 --> 03:19.190
Hello.

03:20.060 --> 03:22.250
And after that we will use.

03:23.090 --> 03:24.010
Full name.

03:24.230 --> 03:25.040
Title.

03:26.370 --> 03:27.540
And that's it.

03:27.660 --> 03:28.980
So now.

03:29.670 --> 03:30.930
The full name.

03:30.960 --> 03:39.600
The full name is used in a sentence that greets the user and after that the title.

03:39.600 --> 03:41.190
So our.

03:42.230 --> 03:42.890
Here.

03:44.230 --> 03:48.200
So our names is going to be uppercase or OC.

03:49.090 --> 03:49.660
Sully.

03:51.270 --> 03:54.090
And again uppercase A.

03:55.180 --> 03:56.200
Academy.

03:59.060 --> 03:59.780
That's it.

04:01.110 --> 04:01.950
So.

04:03.360 --> 04:05.820
No, let's let's run firstly here.

04:05.820 --> 04:08.760
And as you can see here, we got this here.

04:10.090 --> 04:10.690
Hello.

04:10.720 --> 04:12.370
Oxley Academy.

04:17.340 --> 04:21.240
We got these because we have to use this quotation mark.

04:22.070 --> 04:22.910
Not here.

04:22.910 --> 04:28.580
And this quotation mark, not here at the end of this year.

04:29.820 --> 04:31.080
Outside the brace.

04:31.320 --> 04:33.060
Now let's run this.

04:33.620 --> 04:38.270
And as you can see here, we got this as an output.

04:38.270 --> 04:41.480
So you can do a lot with format strings.

04:41.780 --> 04:42.740
So.

04:44.770 --> 04:45.310
Now.

04:45.460 --> 04:48.760
So this quote displays this message as well.

04:48.760 --> 04:55.240
But you signing the message to a variable, We make the final print.

04:55.720 --> 04:57.400
How much simpler here?

04:57.400 --> 05:04.780
So let's instead of this, let's delete this braces, delete this print function.

05:04.780 --> 05:08.380
And now we will write message here.

05:08.770 --> 05:12.970
So we got the first name, last name, full name and message.

05:13.300 --> 05:13.840
All right.

05:14.700 --> 05:22.350
So now we will just print the message and we will get the same output again.
