This is in class work and does not need to be turned in.
1. Let us read some poetry, and see what we can do…
2. Could we count the number of times each vowel is used?
3. Can we break the lines into words?
4. Can we make a function countWords(word) to ask for a word and then count it?
5. What if we search for “see”? How about “see;”? How about “say”, “say,’, “Say”, and “Say,”? What could we do about this?
6. Consider the code below:
def removePunctuation(s):
import string
for c in string.punctuation:
s= s.replace(c,"")
return s
What does this code do? Call this on every line you read in and search for “was”. What changed?
7. Consider the function s.lower(), where s is a string. What does it do? How might this be useful to count words?
8. Can you find and display all the lines that have a certain word? Can we find all lines with a repeated word?
Nothing to turn in – this is just an in class activity.
