Shakespeare: Difference between revisions
|(14 intermediate revisions by the same user not shown)|
>>> lv_counter = 0;
6.Use a for loop (or while loop, if you like) to read through the lines of the file. While you are reading each line, count the number of lines that contains the word "love"
7. Does Shakespeare use a lot of love in his plays? How about other synonyms of "love"?
* Recall that lists in Python can contain <b>
* We may declare our list as such
* Dictionaries are another data structure commonly used in programming. Dictionaries
* Entries in the dictionary are stored <b>
* <b>keys</b> for each entry in the dictionary must be unique, <b> values </b> do not have to be unique.
* For our simplicity, we will use a string as keys.
* The following basic operations
>>> del myDict["Interesting"]
For more information on dictionary: https://docs.python.org/2/tutorial/datastructures.html#dictionaries
====<font color="navy">Lists and Dictionaries Exercises====
<b>List & Iteration Exercise 1:</b>
* Create a new python
* Import the list of characters from <b> A Midsummer Night's Dream </b> by importing <code>summerChar</code> and import the play <code>summerNight</code>
# prints all the characters such as <HELENA> that are in the play A Midsummer Night's Dream
<b>List & Iteration Exercise 2:</b>
* Count how many times
* Print to screen the name <OBERON> and the number of times he spoke.
<b>Demo: Which of Shakespeare's famous tragic heros talks the most?</b>