Page 113 - Trackpad_V2.1_class8
P. 113
CREATING A SINGLE-LINE STRINGS
Single-line strings can be created by enclosing characters inside single or double quotes. It is like
assigning a value to a variable.
Program 4: To create a single-line string
Program4.py
File Edit Format Run Options Window Help
first_name = 'Aadya'
print (first_name)
last_name = 'Kaushal'
print (last_name)
str = ' '
print (str)
Output
Aadya
Kaushal
CREATING 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.
Program 5: To print multiline string
Program5.py
File Edit Format Run Options Window Help
print('''A sequence of
characters are called a string.
Strings are used by programming
languages to manipulate text such
as words and sentences.''')
You will get the following output:
Output
A sequence of
characters are called a string.
Strings are used by programming
languages to manipulate text such
as words and sentences.
Functions, String and List in Python 111

