CHP 5: Python
CHP 5: Python
Chapter 5
Strings
String Literals
Written as a sequence of
characters surrounded by
Sequence of characters that is either single quotes (') or
treated as a single item double quotes (").
• Opening and closing quotation
marks must be the same type
Created (come into existence) the first time they appear in assignment
statements
Consisting of
Two strings can be the strings
combined to form a joined together
new string Represented by
a plus sign
String
Concatenation Combination of strings,
plus signs, functions, Called a string
and methods can be expression
evaluated
String Repetition
• Asterisk operator can be used with strings to
repeatedly concatenate a string with itself
– These are OK