Strings See Chapter 2 u Review constants u Strings, concatenation and repetition 1
Constants u Programmers use all uppercase letters for symbolic constants –Examples: TAX_RATE and STANDARD_DEDUCTION u Constants receive values with an assignment statement = 2 TAX_RATE = 33.5 BOARD_SIZE = 64
String Literals u In Python, a string literal is a sequence of characters enclosed in single or double quotation marks '' and "" represent the empty string Use ''' and """ for multi-line paragraphs –The display formatting follows exactly your given format u For multi-line expressions, use a \ if formatting should be determined when displaying the string 3
String Literals, Examples 4 >>> "This very long sentence extends all the way to \ the next line." 'This very long sentence extends all the way to the next line.'
Escape Sequences u The newline character \n is called an escape sequence 5
String Concatenation You can join two or more strings to form a new string using the concatenation operator + The * operator allows you to build a string by repeating another string a given number of times 6
Required Readings u Fundamentals of Python Sections