Skillyfy provides best Python Training in DELHI NCR. We have a team of experienced Python professionals and trainers who have vested many years in this ever-growing IT industry.
Through our best Python Training course in Delhi you’ll learn all of the Python fundamentals. Each chapter ends with exercises, allowing you to put your new learned skills into practical use for a better understanding. Knowing Python opens a great deal of doors for you as a developer. This blog is about Quotation marks and Special characters in Python course in Delhi NCR.
Quotation Marks and Special Characters
Strings can be created with single quotes or double quotes. There is no difference between the two.
Escaping Characters
To output a string that contains a single quote (e.g., Where’d you get the coconuts?), enclose the string in double quotes:
phrase = “Where’d you get the coconuts?”
Likewise, to output a string that contains a double quote (e.g., The soldier asked, “Are you suggesting coconuts migrate?”), enclose the string in single quotes:
phrase = ‘The soldier asked, “Are you suggesting coconuts migrate?”‘
Sometimes you will want to output single quotes within a string denoted by single quotes or double quotes within a string denoted by double quotes. In such cases, you will need to escape the quotation marks using a backslash (\), like this:
phrase = “The soldier said, \”You’ve got two empty halves of a co »»
conut and you’re bangin’ ’em together.\””
#or
phrase = ‘The soldier said, “You\’ve got two empty halves of a co »»
conut and you\’re bangin\’ \’em together.”‘
Special Characters
The backslash can also be used to escape characters that have special meaning, such as the backslash itself:
phrase = “Use an extra backslash to output a backslash: \\”
Two other common special characters are the linefeed (\n) and horizontal tab (\t).
Escape Sequences
Escape Sequence | Meaning |
\’ | Single quote |
\” | Double quote |
\\ | Backslash |
\n | Linefeed |
\t | Horizontal tab |
Triple Quotes
Triple quotes are used to create multi-line strings. You can use three double quotes16 as shown in the example below:
Code Sample
Code Explanation
The above code will render the following:
Notice that quotation marks can be included within triple-quoted strings without being escaped with a backslash.
In some cases when using triple quotes, you may want to break up your code with a linefeed without having that linefeed show up in your output. You can escape the actual linefeed with a backslash as shown below:
Code Sample
Code Explanation
The above code will render the following:
Notice that the backslashes at the end of lines 1, 3, and 5 prevent line breaks in the output.
This article is contributed by Skillyfy. Skillyfy provides best Python Training institute in DELHI NCR with 100% complete practical demonstrations.
Please call on 7827814720 or email info@skillyfy.com if you want to take more
information about the topic discussed above or any other courses.
Happy Learning !!
Source Url: https://javatrainingindelhi.weebly.com/blog/functional-lambdas-in-java-8