Post date: Sep 20, 2011 6:36:46 PM
Announcements
New Programming project posted (2 sets of CodingBat problems plus 2 programs)
Homework
Take D2L Quiz for Chapter 5, Part 2 (due 10:00pm Thursday) as your are reading pages 131 through 151
Sectons 5.4, 5.5, 5.6, 5.8, and 5.8
Begin Project 3
Lecture Outline
Chapter 5: Sequences, Lists, Strings, and Files
Characters are stored like integers
'A' == chr(65)
'a' == chr(97)
ord('a') == 97
'a' != 97 # legal but 'a' is not equal to 97
Iterate of the sequence of characters in a string with a for loop
s = 'U_of_A!'
for ch in s
print(ch)
split() breaks up a string into a list of substrings where whitespace separates substrings
s = 'Univ of Ariz !'
list = s.split() # Creates the list ['Univ', 'of', 'Ariz', '!']
String methods (these are methods, not functions, hence it is 'string'.upper())
s = 'abc'
s.capitalize() s.center(5) s.lower()
s.rjust(6) s.rfind('b') s.replace('a', 'T')
Methods that appear to change the string, do not
Code demo: Encryption, Decryption using a for loop
Consider Project 3
Do one CodingBat in List-1