::: {#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=week2a2)
-   

```{=html}
<!-- -->
```
-   
-   [This Chapter](../index.html){.dropdown-toggle}
    -   [7.1 Introduction: Iteration](intro-Iteration.html){.reference
        .internal}
    -   [7.2 The for Loop](TheforLoop.html){.reference .internal}
    -   [7.3 Flow of Execution of the for
        Loop](FlowofExecutionoftheforLoop.html){.reference .internal}
    -   [7.4 Strings and for loops](Stringsandforloops.html){.reference
        .internal}
    -   [7.5 Lists and for loops](Listsandforloops.html){.reference
        .internal}
    -   [7.6 The Accumulator
        Pattern](TheAccumulatorPattern.html){.reference .internal}
    -   [7.7 Traversal and the for Loop: By
        Index](TraversalandtheforLoopByIndex.html){.reference .internal}
    -   [7.8 Nested Iteration: Image
        Processing](NestedIterationImageProcessing.html){.reference
        .internal}
    -   [7.9 👩‍💻 Printing Intermediate
        Results](WPPrintingIntermediateResults.html){.reference
        .internal}
    -   [7.10 👩‍💻 Naming Variables in For
        Loops](WPNamingVariablesinForLoops.html){.reference .internal}
    -   [7.11 The Gory Details:
        Iterables](GeneralizedSequences.html){.reference .internal}
    -   [7.12 👩‍💻 Keeping Track of Your Iterator Variable and Your
        Iterable](WPKeepingTrackofYourIteratorVariableYourIterable.html){.reference
        .internal}
    -   [7.13 Glossary](Glossary.html){.reference .internal}
    -   [7.14 Exercises](Exercises.html){.reference .internal}
    -   [7.15 Chapter Assessment](week2a2.html){.reference .internal}
-   
-   
:::
:::
:::

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

::: {#main-content .container role="main"}
::: {#chapter-assessment .section}
[7.15. ]{.section-number}Chapter Assessment[¶](#chapter-assessment "Permalink to this heading"){.headerlink}
============================================================================================================

**Check your understanding**

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_01 component="activecode" question_label="7.15.1"}
::: {#assess_ps_02_01_question .ac_question}
Write one for loop to print out each character of the string
`my_str`{.docutils .literal .notranslate} on a separate line.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_02 component="activecode" question_label="7.15.2"}
::: {#assess_ps_02_02_question .ac_question}
Write one for loop to print out each element of the list
`several_things`{.docutils .literal .notranslate}. Then, write *another*
for loop to print out the TYPE of each element of the list
`several_things`{.docutils .literal .notranslate}. To complete this
problem you should have written two different for loops, each of which
iterates over the list `several_things`{.docutils .literal
.notranslate}, but each of those 2 for loops should have a different
result.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_03 component="activecode" question_label="7.15.3"}
::: {#assess_ps_02_03_question .ac_question}
Write code that uses iteration to print out **the length** of each
element of the list stored in `str_list`{.docutils .literal
.notranslate}.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_04 component="activecode" question_label="7.15.4"}
::: {#assess_ps_02_04_question .ac_question}
Write a program that uses the turtle module **and** a for loop to draw
something. It doesn't have to be complicated, but draw something
different than we have done in the past. (Hint: if you are drawing
something complicated, it could get tedious to watch it draw over and
over. Try setting `.speed(10)`{.docutils .literal .notranslate} for the
turtle to draw fast, or `.speed(0)`{.docutils .literal .notranslate} for
it to draw super fast with no animation.)
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_05 component="activecode" question_label="7.15.5"}
::: {#assess_ps_02_05_question .ac_question}
Write code to count the number of characters in `original_str`{.docutils
.literal .notranslate} using the accumulation pattern and assign the
answer to a variable `num_chars`{.docutils .literal .notranslate}. Do
NOT use the `len`{.docutils .literal .notranslate} function to solve the
problem (if you use it while you are working on this problem, comment it
out afterward!)
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_07 component="activecode" question_label="7.15.6"}
::: {#assess_ps_02_07_question .ac_question}
`addition_str`{.docutils .literal .notranslate} is a string with a list
of numbers separated by the `+`{.docutils .literal .notranslate} sign.
Write code that uses the accumulation pattern to take the sum of all of
the numbers and assigns it to `sum_val`{.docutils .literal .notranslate}
(an integer). (You should use the `.split("+")`{.docutils .literal
.notranslate} function to split by `"+"`{.docutils .literal
.notranslate} and `int()`{.docutils .literal .notranslate} to cast to an
integer).
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_08 component="activecode" question_label="7.15.7"}
::: {#assess_ps_02_08_question .ac_question}
`week_temps_f`{.docutils .literal .notranslate} is a string with a list
of fahrenheit temperatures separated by the `,`{.docutils .literal
.notranslate} sign. Write code that uses the accumulation pattern to
compute the **average** (sum divided by number of items) and assigns it
to `avg_temp`{.docutils .literal .notranslate}. Do not hard code your
answer (i.e., make your code compute both the sum or the number of items
in `week_temps_f`{.docutils .literal .notranslate}) (You should use the
`.split(",")`{.docutils .literal .notranslate} function to split by
`","`{.docutils .literal .notranslate} and `float()`{.docutils .literal
.notranslate} to cast to a float).
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#assess_ps_02_09 component="activecode" question_label="7.15.8"}
::: {#assess_ps_02_09_question .ac_question}
Write code to create a list of numbers from 0 to 67 and assign that list
to the variable `nums`{.docutils .literal .notranslate}. Do not hard
code the list.
:::
:::
:::
:::

::: {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"}
:::
:::

-   [[](Exercises.html)]{#relations-prev}
-   [[](../Conditionals/toctree.html)]{#relations-next}
:::

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

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