Title: String
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

String data type:

- Contains any sequence of characters.
- Requires delimiters to surround the character sequence.
- In Python, we may use either:
Double quotes (")
Single quotes (')

String Expression Examples

"Chicago"
"Chicago is the windy city"
'Detroit'
'Detroit was founded in 1701 by Antoine Cadillac.'

String operators:
Perform operations on two string expressions.

In Python, string operators include:

Operation | Python Operator
Concatenation | +
Repeat | *

String Operator Examples

String Expression | Result
"Thomas " + "Jefferson" | Thomas Jefferson
'Groucho, ' + 'Chico, ' + 'Harpo' | Groucho, Chico, Harpo
"=" * 20 | ====================
"-+" * 10 | -+-+-+-+-+-+-+-+-+-+