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

```{=html}
<!-- -->
```
-   
-   [This Chapter](../index.html){.dropdown-toggle}
    -   [11.1 Introduction:
        Dictionaries](intro-DictionaryGoals.html){.reference .internal}
    -   [11.2 Getting Started with
        Dictionaries](intro-Dictionaries.html){.reference .internal}
    -   [11.3 Dictionary
        operations](Dictionaryoperations.html){.reference .internal}
    -   [11.4 Dictionary methods](Dictionarymethods.html){.reference
        .internal}
    -   [11.5 Aliasing and copying](Aliasingandcopying.html){.reference
        .internal}
    -   [11.6 Introduction: Accumulating Multiple Results In a
        Dictionary](intro-AccumulatingMultipleResultsInaDictionary.html){.reference
        .internal}
    -   [11.7 Accumulating Results From a
        Dictionary](AccumulatingResultsFromaDictionary.html){.reference
        .internal}
    -   [11.8 Accumulating the Best
        Key](AccumulatingtheBestKey.html){.reference .internal}
    -   [11.9 👩‍💻 When to use a
        dictionary](WPChoosingDictionaries.html){.reference .internal}
    -   [11.10 Glossary](Glossary.html){.reference .internal}
    -   [11.11 Exercises](Exercises.html){.reference .internal}
    -   [11.12 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}
:::
:::
:::

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

::: {#assessment-dictionaries .section}
[11.12.1. ]{.section-number}Assessment - Dictionaries[¶](#assessment-dictionaries "Permalink to this heading"){.headerlink}
---------------------------------------------------------------------------------------------------------------------------

::: {.runestone .explainer .ac_section}
::: {#ac10_9_1 component="activecode" question_label="11.12.1.1"}
::: {#ac10_9_1_question .ac_question}
At the halfway point during the Rio Olympics, the United States had 70
medals, Great Britain had 38 medals, China had 45 medals, Russia had 30
medals, and Germany had 17 medals. Create a dictionary assigned to the
variable `medal_count`{.docutils .literal .notranslate} with the country
names as the keys and the number of medals the country had as each key's
value.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_2 component="activecode" question_label="11.12.1.2"}
::: {#ac10_9_2_question .ac_question}
Given the dictionary `swimmers`{.docutils .literal .notranslate}, add an
additional key-value pair to the dictionary with `"Phelps"`{.docutils
.literal .notranslate} as the key and the integer `23`{.docutils
.literal .notranslate} as the value. Do not rewrite the entire
dictionary.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_3 component="activecode" question_label="11.12.1.3"}
::: {#ac10_9_3_question .ac_question}
Add the string "hockey" as a key to the dictionary
`sports_periods`{.docutils .literal .notranslate} and assign it the
value of 3. Do not rewrite the entire dictionary.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_4 component="activecode" question_label="11.12.1.4"}
::: {#ac10_9_4_question .ac_question}
The dictionary `golds`{.docutils .literal .notranslate} contains
information about how many gold medals each country won in the 2016
Olympics. But today, Spain won 2 more gold medals. Update
`golds`{.docutils .literal .notranslate} to reflect this information.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_5 component="activecode" question_label="11.12.1.5"}
::: {#ac10_9_5_question .ac_question}
Create a list of the countries that are in the dictionary
`golds`{.docutils .literal .notranslate}, and assign that list to the
variable name `countries`{.docutils .literal .notranslate}. Do not hard
code this.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_6 component="activecode" question_label="11.12.1.6"}
::: {#ac10_9_6_question .ac_question}
Provided is the dictionary, `medal_count`{.docutils .literal
.notranslate}, which lists countries and their respective medal count at
the halfway point in the 2016 Rio Olympics. Using dictionary mechanics,
assign the medal count value for `"Belarus"`{.docutils .literal
.notranslate} to the variable `belarus`{.docutils .literal
.notranslate}. Do not hardcode this.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_7 component="activecode" question_label="11.12.1.7"}
::: {#ac10_9_7_question .ac_question}
The dictionary `total_golds`{.docutils .literal .notranslate} contains
the total number of gold medals that countries have won over the course
of history. Use dictionary mechanics to find the number of golds Chile
has won, and assign that number to the variable name
`chile_golds`{.docutils .literal .notranslate}. Do not hard code this!
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_8 component="activecode" question_label="11.12.1.8"}
::: {#ac10_9_8_question .ac_question}
Provided is a dictionary called `US_medals`{.docutils .literal
.notranslate} which has the first 70 medals that the United States has
won in 2016, and in which category they have won it in. Using dictionary
mechanics, assign the value of the key `"Fencing"`{.docutils .literal
.notranslate} to a variable `fencing_value`{.docutils .literal
.notranslate}. Remember, do not hard code this.
:::
:::
:::
:::

::: {#assessment-dictionary-accumulation .section}
[11.12.2. ]{.section-number}Assessment - Dictionary Accumulation[¶](#assessment-dictionary-accumulation "Permalink to this heading"){.headerlink}
-------------------------------------------------------------------------------------------------------------------------------------------------

::: {.runestone .explainer .ac_section}
::: {#ac10_9_9 component="activecode" question_label="11.12.2.1"}
::: {#ac10_9_9_question .ac_question}
The dictionary `Junior`{.docutils .literal .notranslate} shows a
schedule for a junior year semester. The key is the course name and the
value is the number of credits. Find the total number of credits taken
this semester and assign it to the variable `credits`{.docutils .literal
.notranslate}. Do not hardcode this -- use dictionary accumulation!
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_10 component="activecode" question_label="11.12.2.2"}
::: {#ac10_9_10_question .ac_question}
Create a dictionary, `freq`{.docutils .literal .notranslate}, that
displays each character in string `str1`{.docutils .literal
.notranslate} as the key and its frequency as the value.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_11 component="activecode" question_label="11.12.2.3"}
::: {#ac10_9_11_question .ac_question}
Provided is a string saved to the variable name `s1`{.docutils .literal
.notranslate}. Create a dictionary named `counts`{.docutils .literal
.notranslate} that contains each letter in `s1`{.docutils .literal
.notranslate} and the number of times it occurs.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_12 component="activecode" question_label="11.12.2.4"}
::: {#ac10_9_12_question .ac_question}
Create a dictionary, `freq_words`{.docutils .literal .notranslate}, that
contains each word in string `str1`{.docutils .literal .notranslate} as
the key and its frequency as the value.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_13 component="activecode" question_label="11.12.2.5"}
::: {#ac10_9_13_question .ac_question}
Create a dictionary called `wrd_d`{.docutils .literal .notranslate} from
the string `sent`{.docutils .literal .notranslate}, so that the key is a
word and the value is how many times you have seen that word.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_14 component="activecode" question_label="11.12.2.6"}
::: {#ac10_9_14_question .ac_question}
Create the dictionary `characters`{.docutils .literal .notranslate} that
shows each character from the string `sally`{.docutils .literal
.notranslate} and its frequency. Then, find the most frequent letter
based on the dictionary. Assign this letter to the variable
`best_char`{.docutils .literal .notranslate}.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_15 component="activecode" question_label="11.12.2.7"}
::: {#ac10_9_15_question .ac_question}
Find the least frequent letter. Create the dictionary
`characters`{.docutils .literal .notranslate} that shows each character
from string `sally`{.docutils .literal .notranslate} and its frequency.
Then, find the least frequent letter in the string and assign the letter
to the variable `worst_char`{.docutils .literal .notranslate}.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_16 component="activecode" question_label="11.12.2.8"}
::: {#ac10_9_16_question .ac_question}
Create a dictionary named `letter_counts`{.docutils .literal
.notranslate} that contains each letter and the number of times it
occurs in `string1`{.docutils .literal .notranslate}. **Challenge:**
Letters should not be counted separately as upper-case and lower-case.
Intead, all of them should be counted as lower-case.
:::
:::
:::

::: {.runestone .explainer .ac_section}
::: {#ac10_9_17 component="activecode" question_label="11.12.2.9"}
::: {#ac10_9_17_question .ac_question}
Create a dictionary called `low_d`{.docutils .literal .notranslate} that
keeps track of all the characters in the string `p`{.docutils .literal
.notranslate} and notes how many times each character was seen. Make
sure that there are no repeats of characters as keys, such that "T" and
"t" are both seen as a "t" for example.
:::
:::
:::
:::
:::

::: {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}
-   [[](../Functions/toctree.html)]{#relations-next}
:::

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

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