Strings:
If you want to enter text in python, you have to use a string. A string is created by entering text between two single or double quotation marks ("Text" or 'Text').
Some characters can't be directly included in a string. Say for example the double and single quotes can not be directly included in a double or single quote string. This will end the code prematurely and can cause error.You can enter these kind of symbols by using { \ } before them. Other common characters that must be escaped are newlines and backslashes. Double quote only need to be escaped in double quote and is true for single quote as well.
Note : Backslash can also be used to escape tabs, arbitrary unicode characters, and various other things that can't be reliably printed. These characters are called as escape characters.
Newlines:
We can create a newline or escape a newline in python using {\n} in place from where you want to start the new line. But python provides an easy way to avoid manually written "\n"
to escape to a newline in a string. The method is as : Create a string with three sets of quotes , and newlines that are created by pressing enter are automatically escape.
String Operations:
" Concatenation : The state of being linked together as in a chain or union in a linked series "
As with the integers and floats, strings in python can be added, using a process called concatenation, which can be done on any two strings.
When concatenating a string it doesn't matter whether they've been created with single or double quotes.Even if your strings contain numbers they are still added as strings rather than integers.
Adding a string to a number produces an error, even they might look similar they are two different entities.
Adding a string to a number produces an error, even they might look similar they are two different entities.
Nice Information
ReplyDeletePower BI Online Training
Power BI Online Course