Python Workshops for Beginners/Saturday September 27th homework: Difference between revisions

imported>Ynasser
imported>Ehashman
 
(8 intermediate revisions by 4 users not shown)
Line 1:
Hopefully you haven't forgotten too much from the last few sessions. Here are some homework problems you should try out before the next session on October 25. The exercises are based on the Shakespeare and Wordplay exercises from last time. Regardless of which afternoon session you attended, you should be able to do both, unless otherwise specified.
 
= September 27 Homework Exercises =
 
The exercises are based on the Shakespeare and Wordplay exercises from last time. Regardless of which afternoon session you attended, you should be able to do both, unless otherwise specified.
 
Remember: indentation in Python matters!
Line 20 ⟶ 24:
To get started, import the two modules which provide the character list and text of the play:
<pre>
>>> importfrom summerChar import characters
>>> importfrom summerNight import lines
</pre>
 
Note: characterCharacter names are stored inwith theall formcapital <NAME>letters, which is how their parts are represented in the script.
To access the list of characters, set the following variable:
<pre>
>>> characters = summerChar.SummerChar
</pre>
 
Each line of the play is an entry in the list. At the end of some lines you may see things like "/r" or "/n". You can ignore these symbols, as they're just special characters used to denote things such as new lines (like when you press the enter key) or tabs.
Note: character names are stored in the form <NAME>, which is how their parts are represented in the script.
 
To access the text of the play as a list (each line is an entry in the list):
<pre>
>>> lines = summerNight.SummerNight
</pre>
 
 
Line 62 ⟶ 58:
'''Exercise 3'''
 
This exercise requires knowledge of regular expressions. If you need solutions to the wordplayWordplay exercises to see exampleexamples of regular expressions in action, [https://github.com/jesstess/Wordplay they can be found here].
 
Write a program to find all words in the scrabble dictionary which contain a q which isn't followed by a u.
Anonymous user