Tags: %TAGME{ tpaction="" web="Main" tag="" }% view all tags

Emily Dickinson Experiment (Part 1)


Due Oct 15, 11:55 pm

You will turn in Repl.it links for 2 and 8

1. Lets' 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. Use the code from #3 to count the "was", and "was,". Why is there a difference? 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 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 counts words?

8. Can you find and display all the lines that have a repeated word? Can you include the word, and the number of occurances in the line for each repeated word?

9. What would it take to create a list of all of the unique words and write them to a file, one word per line? More on this tonight!


Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-01-23 - JimSkon
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback