Python Workshops for Beginners/Saturday September 27th homework: Difference between revisions
Content added Content deleted
imported>Ynasser |
imported>Ynasser |
||
Line 10: | Line 10: | ||
== Shakespeare Exercises == |
== Shakespeare Exercises == |
||
Here's a link to the Shakespeare handout from last time: [] |
|||
⚫ | |||
⚫ | |||
'''Exercise 1''' |
'''Exercise 1''' |
||
Line 16: | Line 18: | ||
Write a program that creates a dictionary with keys as the characters from ''A Midsummer Night's Dream'' and the values being the number of times each particular character had a speaking part. |
Write a program that creates a dictionary with keys as the characters from ''A Midsummer Night's Dream'' and the values being the number of times each particular character had a speaking part. |
||
To get started, import the two modules which provide the character list and text of the play: |
|||
<pre> |
|||
>>> import summerChar |
|||
>>> import summerNight |
|||
</pre> |
|||
To access the list of characters, set the following variable: |
|||
<pre> |
|||
>>> characters = summerChar.SummerChar |
|||
</pre> |
|||
To access the text of the play as a list (each line is an entry in the list): |
|||
<pre> |
|||
>>> lines = summerNight.SummerNight |
|||
</pre> |
|||
'''Exercise 2''' |
'''Exercise 2''' |
||