Welcome to this lecture in this lecture we'll see about the formatting techniques of this string and
some other operator operations concept in this lecture.
So all the formatting Python uses a C style formatting to create the new format it is string and that
can be done by using the modulus sign.
So the module assigned that is this operator over here in the screen is used to format a set of variables
that is enclosed by the tuple which is basically a fixed size the list will learn about the tuple in
the upcoming lecture.
But just remember it is a type of a list which is a together with a formal string which contains a normal
text together without a comment is specified.
So let's learn about this and let's see how these percentages and person days D works together.
So let's see and let's make a real quick script over here to learn about the formatting so let me just
press control and to create the new file which is our script.
You can also simply go to the file and create the new file to create a script and let me just save this
file is test da boy which is the extension of a python file.
Let's go to the stack stop and save it here.
So we want to just create the folder first which you'll be the string and I'll say John is inside this
name folder and now we have to make use of this print method which is going to print to us whatever
inside the value is.
So here I want to this pass.
Hello and I'll say hello.
It's.
And after that I'll say on the exclamation mark or come over me.
And after that I want to give this percentage.
Yes.
Which is is specified over here which is basically your argument specified which is a special symbol
which will just replace our name now.
So I'll just say that after this.
Let me just put here again the person days and the name of a folder over here which will be name.
And now let me just close this print method.
So what we have done here is we have this call called This is specified argument specified percentages
which is for this string.
If it was case for the number it would be Poisson d d.
For now it is percentages which is for this zone.
So let me just say this and press your file then you'll see.
Hello.
East end zone.
So instead of this percent is yes.
Place.
So let's go again back to this script now.
And if you see the output over here in the place of this person days yes we have just included the name
which is John.
So this is the formatting technique we have made a use of this formatting technique in this selector
by using these arguments specified which is percentages.
So let's make an order program using this same SBC fire.
But now I'll just say a name is
Kerry again.
And now let me just add another which is the integer here that is is twenty three.
And let me just print again my formatting this.
So I'll say percentages which is for this name hurry and is percentages D for the AIDS.
And as I say years all.
So I'm just formatting over here and now that we disclosed this with purchase in days and now there
is a two thing that need to be passed.
So we'll just pass inside this span and this is that is name and AIDS and let me disclose first dependencies
and disclose this printed statement to.
So we have now created another program here using the same argument to specify.
But now we have included would this string end the NDA inside the same printing statement.
So let's save this now and press five then you could see how he is 23 years old which has been replaced
in here argument to specify.
So instead of this Nias it will be hurry and instead of this deem it will be 20 30.
So this is basically you're specified for this argument are basically for this value.
Name and age.
So this the one way to format the sentence.
So there is another way to format this using the format statement.
So we are going to do that in this lecture.
So let's start this.
So first of all let me just create the script over here so instead of the scripting script let's go
to the cell and let's make a program right here.
So I'll say you should be let me say 89 and a Y should be like we said three.
So if I just sit into now I have created the x value and the y value so let's print this in by formatting
basically using this string formatting technique.
So we have learned by using the argument specify a percentage yes in percentages D for the string and
the number respectively.
But now will make use of a format method in this section.
So I'll save the value of yucks is.
So now if you are using the format method you have to give this curly braces.
And why is curly braces.
So instead of this curly braces.
Now will this add this format matter and X come my way will be passed over here.
So now what we have done here is we have this spring.
This is string now and it is saying the value of x is and we have given the empty space over here where
this X will be injected and the Y is where y will be injected but if we just change this values.
So let me the spicier first Y then X then the y value is is three will be inserted in this X in the
Y has the value of X. So this format has to be in the order weights you want to the spots your value.
So in this case I want to pass the x value which is eighty nine in here and a y value is three in this
is specified in this place holder.
So we have to make use of this format method.
So this format method is called upon.
This is string so anybody you are calling the method which is the method of that class which is this
is string you are putting these dart or a period to call upon that is string.
So if I just sit into over here then you will see the value of the X is 89 and Y is 3 which is the value
we just assigned over here.
So we can do same of these by this format method.
So let me create another program.
So let me say like is
Python now lists print saying I like and place although which is basically the quality basis.
And this is the string and we have to call format method so just give dot and format methods would be
called and instead of this place holder you have to pass here like so let's close this and hit into
the new see I like Python.
So this is the way to format every string and it is a best way to do that.
So let's do something like first of all input something from the user endless format that so first of
all as a info and this call this method which is input meter which is going to take a string from the
user.
So I just approve the message saying into your name and now up to this into their name.
I'm going to strip strip all the curly braces so here I'll see into your name.
And it would be such an end if you just say this then now if you see the info.
It would be only such in so it has a stripped all the spaces that we're just passing by this is strip
metal.
So this is strip method is going to strip all these spaces that you pass the idea.
So if you see any spaces has been thus torn down or basically has been it is in this info and only sorting
has been interred so let's format it.
So as a print your name is this hollow and call that format meter pass your name that user has this
input here which is the info and let's close this.
Then you'll see your name is satin which is the user just in total were here from the input meter.
So this is the way to format your output which is a string.
So basically we just made use of the place holders and the format method and the argument is specified
that this person did this in person it is D.
In this letter to this format output.
So in the next lecture was the import some of the classes.
And we'll see the documentation how to do that in the next lecture will be interesting.
Let's assume the next one.