{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

warmup 5.htm.pdf - COM110 Fall 2014 Warm-­‐up exercise 5...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COM110 Fall 2014 Warm-­‐up exercise 5 Due Wed, Sept 24 1. Finish the vowel coun1ng program you started in class. So far we: · opened and read in the text from a text file, then · counted the number of occurrences of the [email protected] “i” (both lower case and upper case). Our code looked something like this: 2. The goal above was to essen1ally write the underlying code for the built-­‐in Python string func1on str.count(“i”) without resor1ng to using any built-­‐in Python string func1ons. But most programming languages don’t even give you a way to automa1cally loop through the characters of a string like this. Instead, they would make you index into the string to retrieve each character. So your loop would count through the posi%ons or indices of the string, rather than looping through the characters directly, like this: Code this up. Test it and make sure it works, and comment each line to explain how it works. 3. Now, you should: · also count the number of occurrences of the [email protected] “e” and “o” · output which of the three vowels (“i,” “e,” or “o”) occurred the most. · (Hint: you will need a non-­‐trivial if statement for the output step. There are mul1ple correct ways to structure the if statement(s). You only need to find one way, but you should try to think of the other ways if you have extra 1me. Since a discussion of the various solu1ons to this may be found in Sec1on 7.5 of Zelle, which was part of your assigned reading, everyone should be able to submit a correct solu1on to this.) 4. GeXng graphics running. (No need to hand this one in, but be sure to complete before lecture on Wed so you will be ready for class.) Download and save the file graphics.py to a folder where you save your python programs. Get it from here. Then download and save graphicswarmup.py into the same place where you saved the graphics.py module. Open graphicswarmup.py in IDLE and test it out. Play around with the code to try to figure out what each line does. (Comment lines out, try changing them, etc.) ...
View Full Document

{[ snackBarMessage ]}