Page 149 - Plus_V2.2_C8_Flipbook
P. 149
Program 1: To create a string.
Multiline Strings
A multiline string in Python begins and ends with either three single quotes or three double quotes.
Any quotes, tabs, or newlines in between the “triple quotes” are considered part of the string.
Using Escape Sequences with Strings
Escape sequences or characters are used to insert special characters that are invalid in Python.
Quotes are special characters and to insert them in a string we must escape them with a \ character
in front of them.
An escape sequence is a sequence of characters that does not represent itself when used inside a
character or string. It is typically used to specify actions such as carriage returns and tab movements.
The backslash (\) is a special character and is also known as the escape character in Python. It is used
to represent white space characters, for example, '\t' for tab, '\n' for new line, and '\r' is for carriage
return.
Program 2: To print multiline strings.
You will get the following output:
Functions and String in Python 147

