::: {#navbar .navbar .navbar-default .navbar-fixed-top role="navigation"}
::: {.container}
::: {.navbar-header}
[]{.icon-bar} []{.icon-bar} []{.icon-bar}

<div>

[![](../_static/img/RAIcon.png)](/runestone/default/user/login){.brand-logo}
[fopp](../index.html){#rs-book-toc-link .navbar-brand}

</div>
:::

::: {.navbar-collapse .collapse .navbar-ex1-collapse}
-   
-   []{#ad_warning}
-   []{#browsing_warning}
-   
-   [*[Search]{.visuallyhidden
    aria-label="Search"}*](#){.dropdown-toggle}
    -   [Table of Contents](../index.html)

    -   [Book Index](../genindex.html)

    -   

    -   ::: {.input-group}
        :::
-   
-   [*[User]{.visuallyhidden aria-label="User"}*](#){.dropdown-toggle}
    -   []{.loggedinuser}

    -   

    -   [Course Home](/ns/course/index)

    -   [Assignments](/assignment/student/chooseAssignment)

    -   [Practice](/runestone/assignments/practice)

    -   [[Peer Instruction
        (Instructor)](/runestone/peer/instructor.html)]{#inst_peer_link}

    -   [Peer Instruction (Student)](/runestone/peer/student.html)

    -   

    -   [Change Course](/runestone/default/courses)

    -   

    -   [[Instructor\'s
        Page](/runestone/admin/index)]{#ip_dropdown_link}

    -   [Progress Page](/runestone/dashboard/studentreport)

    -   

    -   [Edit Profile](/runestone/default/user/profile){#profilelink}

    -   [Change
        Password](/runestone/default/user/change_password){#passwordlink}

    -   [Register](/runestone/default/user/register){#registerlink}

    -   [Login](#)

    -   ::: {.slider .round}
        :::

        Dark Mode
-   
-   [[*[Scratch Activecode]{.visuallyhidden
    aria-label="Scratch Activecode"}*](javascript:runestoneComponents.popupScratchAC())]{#scratch_ac_link}
-   
-   [*[Help]{.visuallyhidden aria-label="Help"}*](#){.dropdown-toggle}
    -   [FAQ](http://runestoneinteractive.org/pages/faq.html)
    -   [Instructors Guide](https://guide.runestone.academy)
    -   
    -   [About Runestone](http://runestoneinteractive.org)
    -   [Report A
        Problem](/runestone/default/reportabug?course=fopp&page=Exercises)
-   

```{=html}
<!-- -->
```
-   
-   [This Chapter](../index.html){.dropdown-toggle}
    -   [10.1 Introduction: Working with Data
        Files](intro-WorkingwithDataFiles.html){.reference .internal}
    -   [10.2 Reading a File](ReadingaFile.html){.reference .internal}
    -   [10.3 Alternative File Reading
        Methods](AlternativeFileReadingMethods.html){.reference
        .internal}
    -   [10.4 Iterating over lines in a
        file](Iteratingoverlinesinafile.html){.reference .internal}
    -   [10.5 Finding a File in your
        Filesystem](FindingaFileonyourDisk.html){.reference .internal}
    -   [10.6 Using with for Files](With.html){.reference .internal}
    -   [10.7 Recipe for Reading and Processing a
        File](FilesRecipe.html){.reference .internal}
    -   [10.8 Writing Text Files](WritingTextFiles.html){.reference
        .internal}
    -   [10.9 CSV Format](CSVFormat.html){.reference .internal}
    -   [10.10 Reading in data from a CSV
        File](ReadingCSVFiles.html){.reference .internal}
    -   [10.11 Writing data to a CSV
        File](WritingCSVFiles.html){.reference .internal}
    -   [10.12 👩‍💻 Tips on Handling
        Files](WPTipsHandlingFiles.html){.reference .internal}
    -   [10.13 Glossary](Glossary.html){.reference .internal}
    -   [10.14 Exercises](Exercises.html){.reference .internal}
    -   [10.15 Chapter Assessment](ChapterAssessment.html){.reference
        .internal}
-   
-   
:::
:::
:::

::: {#continue-reading .container}
:::

::: {#main-content .container role="main"}
::: {#adcopy_1 .adcopy style="display: none;"}
#### Before you keep reading\...

Runestone Academy can only continue if we get support from individuals
like you. As a student you are well aware of the high cost of textbooks.
Our mission is to provide great books to you for free, but we ask that
you consider a \$10 donation, more if you can or less if \$10 is a
burden.

::: {.donateb}
[Support Runestone Academy Today](/runestone/default/donate?ad=1){.btn
.btn-info}
:::

::: {#adcopy_2 .adcopy style="display: none;"}
#### Before you keep reading\...

Making great stuff takes time and \$\$. If you appreciate the book you
are reading now and want to keep quality materials free for other
students please consider a donation to Runestone Academy. We ask that
you consider a \$10 donation, but if you can give more thats great, if
\$10 is too much for your budget we would be happy with whatever you can
afford as a show of support.

::: {.donateb}
[Support Runestone Academy Today](/runestone/default/donate?ad=2){.btn
.btn-info}
:::
:::
:::

::: {#exercises .section}
[10.14. ]{.section-number}Exercises[¶](#exercises "Permalink to this heading"){.headerlink}
===========================================================================================

Below are the datafiles that you have been using so far, and will
continue to use for the rest of the chapter.

The file below is `travel_plans.txt`{.docutils .literal .notranslate}.

``` {#travel_plans.txt}
This summer I will be travelling.
I will go to...
Italy: Rome
Greece: Athens
England: London, Manchester
France: Paris, Nice, Lyon
Spain: Madrid, Barcelona, Granada
Austria: Vienna
I will probably not even want to come back!
However, I wonder how I will get by with all the different languages.
I only know English!
```

The file below is `school_prompt.txt`{.docutils .literal .notranslate}.

``` {#school_prompt.txt}
Writing essays for school can be difficult but
many students find that by researching their topic that they
have more to say and are better informed. Here are the university
we require many undergraduate students to take a first year writing requirement
so that they can
have a solid foundation for their writing skills. This comes
in handy for many students.
Different schools have different requirements, but everyone uses
writing at some point in their academic career, be it essays, research papers,
technical write ups, or scripts.
```

The file below is `emotion_words.txt`{.docutils .literal .notranslate}.

``` {#emotion_words.txt}
Sad upset blue down melancholy somber bitter troubled
Angry mad enraged irate irritable wrathful outraged infuriated
Happy cheerful content elated joyous delighted lively glad
Confused disoriented puzzled perplexed dazed befuddled
Excited eager thrilled delighted
Scared afraid fearful panicked terrified petrified startled
Nervous anxious jittery jumpy tense uneasy apprehensive
```

::: {#files_ex_1 .full-width .container .question component="question" question_label="10.14.1"}
1.  <div>
    >
    > ::: {#q1 .alert .alert-warning component="tabbedStuff"}
    > ::: {component="tab" tabname="Question"}
    > ::: {.runestone .explainer .ac_section}
    > ::: {#ac9_9_1 component="activecode" question_label="10.14.2"}
    > ::: {#ac9_9_1_question .ac_question}
    > The following sample file called `studentdata.txt`{.docutils
    > .literal .notranslate} contains one line for each student in an
    > imaginary class. The students name is the first thing on each
    > line, followed by some exam scores. The number of scores might be
    > different for each student.
    >
    > ``` {#studentdata.txt}
    > joe 10 15 20 30 40
    > bill 23 16 19 22
    > sue 8 22 17 14 32 17 24 21 2 9 11 17
    > grace 12 28 21 45 26 10
    > john 14 32 25 16 89
    > ```
    >
    > Using the text file `studentdata.txt`{.docutils .literal
    > .notranslate} write a program that prints out the names of
    > students that have more than six quiz scores.
    > :::
    > :::
    > :::
    > :::
    >
    > ::: {component="tab" tabname="Answer"}
    > ::: {.runestone .explainer .ac_section}
    > ::: {#ch_files_q1answer component="activecode" question_label="10.14.3"}
    > ::: {#ch_files_q1answer_question .ac_question}
    > :::
    > :::
    > :::
    > :::
    > :::
    >
    > </div>
:::

::: {#files_ex_2 .full-width .container .question component="question" question_label="10.14.4"}
2.  <div>
    >
    > ::: {#q2 .alert .alert-warning component="tabbedStuff"}
    > ::: {component="tab" tabname="Question"}
    > ::: {.runestone .explainer .ac_section}
    > ::: {#ac9_9_2 component="activecode" question_label="10.14.5"}
    > ::: {#ac9_9_2_question .ac_question}
    > Create a list called `destination`{.docutils .literal
    > .notranslate} using the data stored in
    > `travel_plans.txt`{.docutils .literal .notranslate}. Each element
    > of the list should contain a line from the file that lists a
    > country and cities inside that country. Hint: each line that has
    > this information also has a colon `:`{.docutils .literal
    > .notranslate} in it.
    > :::
    > :::
    > :::
    > :::
    > :::
    >
    > </div>
:::

::: {#files_ex_3 .full-width .container .question component="question" question_label="10.14.6"}
3.  <div>
    >
    > ::: {#q3 .alert .alert-warning component="tabbedStuff"}
    > ::: {component="tab" tabname="Question"}
    > ::: {.runestone .explainer .ac_section}
    > ::: {#ac9_9_3 component="activecode" question_label="10.14.7"}
    > ::: {#ac9_9_3_question .ac_question}
    > Create a list called `j_emotions`{.docutils .literal .notranslate}
    > that contains every word in `emotion_words.txt`{.docutils .literal
    > .notranslate} that begins with the letter "j".
    > :::
    > :::
    > :::
    > :::
    > :::
    >
    > </div>
:::

::: {#contributed-exercises .section}
[10.14.1. ]{.section-number}Contributed Exercises[¶](#contributed-exercises "Permalink to this heading"){.headerlink}
---------------------------------------------------------------------------------------------------------------------
:::
:::

::: {style="width: 100%"}
::: {ea-publisher="runestoneacademy" ea-type="image" style="display: flex; justify-content: center"}
:::
:::

::: {#scprogresscontainer}
You have attempted []{#scprogresstotal} of []{#scprogressposs}
activities on this page

::: {#subchapterprogress aria-label="Page progress"}
:::
:::

-   [[](Glossary.html)]{#relations-prev}
-   [[](ChapterAssessment.html)]{#relations-next}
:::

::: {.container}
[]{#numuserspan}[]{.loggedinuser} \| [Back to top](#)

© Copyright 2017 bradleymiller. Created using
[Runestone](http://runestoneinteractive.org/) 7.2.10.
:::
