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

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

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

  • Fall '15
  • Cannon

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern