::: {#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}
    -   [9.1 Introduction: Transforming
        Sequences](intro-SequenceMutation.html){.reference .internal}
    -   [9.2 Mutability](Mutability.html){.reference .internal}
    -   [9.3 List Element Deletion](ListDeletion.html){.reference
        .internal}
    -   [9.4 Objects and
        References](ObjectsandReferences.html){.reference .internal}
    -   [9.5 Aliasing](Aliasing.html){.reference .internal}
    -   [9.6 Cloning Lists](CloningLists.html){.reference .internal}
    -   [9.7 Mutating Methods](MutatingMethods.html){.reference
        .internal}
    -   [9.8 Append versus
        Concatenate](AppendversusConcatenate.html){.reference .internal}
    -   [9.9 Non-mutating Methods on
        Strings](NonmutatingMethodsonStrings.html){.reference .internal}
    -   [9.10 String Format Method](StringFormatting.html){.reference
        .internal}
    -   [9.11 f-Strings](FStrings.html){.reference .internal}
    -   [9.12 The Accumulator Pattern with
        Lists](TheAccumulatorPatternwithLists.html){.reference
        .internal}
    -   [9.13 The Accumulator Pattern with
        Strings](TheAccumulatorPatternwithStrings.html){.reference
        .internal}
    -   [9.14 👩‍💻 Accumulator Pattern
        Strategies](WPAccumulatorPatternStrategies.html){.reference
        .internal}
    -   [9.15 👩‍💻 Don't Mutate A List That You Are Iterating
        Through](WPDontMutateAListYouIterateThrough.html){.reference
        .internal}
    -   [9.16 Summary](Glossary.html){.reference .internal}
    -   [9.17 Exercises](Exercises.html){.reference .internal}
    -   [9.18 Chapter Assessment - List
        Methods](week4a1.html){.reference .internal}
-   
-   
:::
:::
:::

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

::: {#main-content .container role="main"}
::: {#exercises .section}
[9.17. ]{.section-number}Exercises[¶](#exercises "Permalink to this heading"){.headerlink}
==========================================================================================

1.  ::: {#q1 .alert .alert-warning component="tabbedStuff"}
    ::: {component="tab" tabname="Question"}
    ::: {.runestone .explainer .ac_section}
    ::: {#ac8_11_1 component="activecode" question_label="9.17.1"}
    ::: {#ac8_11_1_question .ac_question}
    For each word in the list `verbs`{.docutils .literal .notranslate},
    add an -ing ending. Overwrite the old list so that `verbs`{.docutils
    .literal .notranslate} has the same words with `ing`{.docutils
    .literal .notranslate} at the end of each one.
    :::
    :::
    :::
    :::
    :::

2.  ::: {#q2 .alert .alert-warning component="tabbedStuff"}
    ::: {component="tab" tabname="Question"}
    ::: {.runestone .explainer .ac_section}
    ::: {#ac8_11_2 component="activecode" question_label="9.17.2"}
    ::: {#ac8_11_2_question .ac_question}
    In XYZ University, upper level math classes are numbered 300 and up.
    Upper level English classes are numbered 200 and up. Upper level
    Psychology classes are 400 and up. Create two lists,
    `upper`{.docutils .literal .notranslate} and `lower`{.docutils
    .literal .notranslate}. Assign each course in `classes`{.docutils
    .literal .notranslate} to the correct list, `upper`{.docutils
    .literal .notranslate} or `lower`{.docutils .literal .notranslate}.
    HINT: remember, you can convert some strings to different types!
    :::
    :::
    :::
    :::
    :::

3.  ::: {#q3 .alert .alert-warning component="tabbedStuff"}
    ::: {component="tab" tabname="Question"}
    ::: {.runestone .explainer .ac_section}
    ::: {#ac8_11_3 component="activecode" question_label="9.17.3"}
    ::: {#ac8_11_3_question .ac_question}
    Starting with the list myList = \[76, 92.3, 'hello', True, 4, 76\],
    write Python statements to do the following:

    1.  Append "apple" and 76 to the list.

    2.  Insert the value "cat" at position 3.

    3.  Insert the value 99 at the start of the list.

    4.  Find the index of "hello".

    5.  Count the number of 76s in the list.

    6.  Remove the first occurrence of 76 from the list.

    7.  Remove True from the list using `pop`{.docutils .literal
        .notranslate} and `index`{.docutils .literal .notranslate}.
    :::
    :::
    :::
    :::

    ::: {component="tab" tabname="Answer"}
    ::: {.runestone .explainer .ac_section}
    ::: {#answer8_11_3 component="activecode" question_label="9.17.4"}
    ::: {#answer8_11_3_question .ac_question}
    :::
    :::
    :::
    :::

    ::: {component="tab" tabname="Discussion"}
    [Show Comments](#disqus_thread){.disqus_thread_link}
    :::
    :::

4.  ::: {#q4 .alert .alert-warning component="tabbedStuff"}
    ::: {component="tab" tabname="Question"}
    ::: {.runestone .explainer .ac_section}
    ::: {#ac13_5_3 component="activecode" question_label="9.17.5"}
    ::: {#ac13_5_3_question .ac_question}
    The module `keyword`{.docutils .literal .notranslate} determines if
    a string is a keyword. e.g. `keyword.iskeyword(s)`{.docutils
    .literal .notranslate} where `s`{.docutils .literal .notranslate} is
    a string will return either `True`{.docutils .literal .notranslate}
    or `False`{.docutils .literal .notranslate}, depending on whether or
    not the string is a Python keyword. Import the `keyword`{.docutils
    .literal .notranslate} module and test to see whether each of the
    words in list `test`{.docutils .literal .notranslate} are keywords.
    Save the respective answers in a list, `keyword_test`{.docutils
    .literal .notranslate}.
    :::
    :::
    :::
    :::
    :::

5.  ::: {#q5 .alert .alert-warning component="tabbedStuff"}
    ::: {component="tab" tabname="Question"}
    ::: {.runestone .explainer .ac_section}
    ::: {#ac13_5_4 component="activecode" question_label="9.17.6"}
    ::: {#ac13_5_4_question .ac_question}
    The `string`{.docutils .literal .notranslate} module provides
    sequences of various types of Python characters. It has an attribute
    called `digits`{.docutils .literal .notranslate} that produces the
    string '0123456789'. Import the module and assign this string to the
    variable `nums`{.docutils .literal .notranslate}. Below, we have
    provided a list of characters called `chars`{.docutils .literal
    .notranslate}. Using `nums`{.docutils .literal .notranslate} and
    `chars`{.docutils .literal .notranslate}, produce a list called
    `is_num`{.docutils .literal .notranslate} that consists of tuples.
    The first element of each tuple should be the character from
    `chars`{.docutils .literal .notranslate}, and the second element
    should be a Boolean that reflects whether or not it is a Python
    digit.
    :::
    :::
    :::
    :::
    :::

::: {#contributed-exercises .section}
[9.17.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}
-   [[](week4a1.html)]{#relations-next}
:::

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

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