#pythonforbeginners #pythonstrings #srtingformatinginpython #pythontutorial #basicsofpython #learnpythonprogramming #pythonprogrammingforbeginners
__________________________________________________________________
following are the chapters of this lecture |
00:00 INTRODUCTION
00:40 F'STRING
01:36 EXAMPLES OF F'STRING
02:15 LIMITATIONS OF F'STRINGS
03:08 FORMAT STRINGS
06:38 COONCLUSIONS
_____________________________________________________________
PYTHON STRINGS | STRINGS FORMATING IN PYTHON | STRING TO INTIGER IN PYTHON | HOW TO FORMAT STRINGS |
Very often in our programmes, we'll be dealing with numbers.
But almost as often, if not more,
we will want to deal with text.
The user will be giving us some text
that we want to interact with.
We will be doing some processing on it,
we will be wanting to print some text out to the screen,
and that is where the next datatype comes in.
In Python, we've got another type called strings
that are used to contain text like characters,
symbols, numbers, or anything else we want.
Here's our first string that I'm gonna call my string
and it contains the value, hello world.
So a couple of things about this string is
that it is surrounded by double quotation marks.
You can also use single quotations mark if you like,
but it's important that the start
and the end quotation mark match.
So they have to be the same,
you can't mix and match them.
So this here would be invalid because the start quote
and the end quote are different.
I like using double quotation marks, but that's just me.
You can use whichever one you like.
This string here contains the characters H, E, L, L,
and so on, including the comma and the space
and the exclamation mark.
When Python looks at this string, it knows nothing about it.
It doesn't care what its contents are.
It doesn't have any meaning like the number 30 does
because you can do maths on it, for example.
A string doesn't have any intrinsic meaning for Python.
All it's used for is to carry these characters.
For example, you can use it to print some information out
to the user, like hello world.
If you wanted to print that out,
you can store it inside a string and then print it.
As an aside, remember you can always use the value itself
instead of a variable inside the print function here
if you prefer.
Sometimes you'll want to use one quotation mark
or the other depending on the contents of the string.
So if you've got a string with quotes,
then you'll want to use the double quotes,
such as, hello, it's me.
Here, you definitely want to use the double quotation marks
on the outside because you've got a single quotation mark
on the inside.
If you were to use single quotation marks throughout,
then this part here is not included in the string
because the string ends here.
If you run this, you'll get an error.
Similarly, you may want to use the single quotation marks
on the outside and the double quotation marks
on the inside in some occasions.
For example, if you have something like this.
Here we've got a string
and inside the string we've got a bunch of characters.
Once Python realises that you're dealing with a string
you can put whatever you want inside it, and in this case
we are putting the quotation marks inside it.
He said, and then open quotes, you are amazing, yesterday.
This is totally fine because these quotation marks
here don't signal another string to Python,
they are just a character inside the string.
Finally, if you really wanted
to always use the same quotation marks, you can do.
So I'm gonna turn this into a double quotation mark string.
And now you can see that these things here are not part
of the string, they are coloured differently.
However, if you put a backslash in front of these quotes,
Python will no longer treat them
as characters used to signal a string.
Now they are part of the string itself.
I highly discourage you from doing this,
but you may see it every now and then in code
so I wanted to tell you what it means.
When you do this, this is called escaping
and it's quite a common thing to do in some occasions.
But when you're dealing with strings like this,
#pythonstrings
#pythonstringshindi
#pythonstringinterviewquestions
#pythonprogramming
#pythonstringtoint
#pythonstringinput
#pythonstringtointegerconversion
#pythonstringlist
#pythonstringtointeger
#pythonstringmethods
#pythonstringformatting
#python_strings_f
#string_operations_in_python_with_examples
#string_data_type_in_python
#string_in_python_example
#string_operations_in_python_with_examples_list_in_python
#string_in_python_w3schools
#input_string_in_python
#string_slicing_in_python
#python_f_string