# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment
responses = initialize_assignment("9_dictionaries_q", "week_2", "lecture", assignment_points = 7.0, assignment_tag = 'week2-lecture')
# Initialize Otter
import otter
grader = otter.Notebook("9_dictionaries_q.ipynb")
โ ๐ฉบ Chevalier Jackson Collection Problem#
The Chevalier Jackson Collection contains thousands of objects extracted from patientsโ airways and esophagi. These include items such as safety pins, coins, buttons, needles, toy parts, dentures, animal bones, keys, and poker chips.
Your Task:#
Define an Object Dictionary:
Create a dictionary called
object_info
to represent a single item in the collection.The dictionary should include the following keys:
catalog_number
: A string, e.g., โCJC-001โ.description
: A string, e.g., โOpen safety pinโ.type
: A string, e.g., โForeign Bodyโ.year_removed
: An integer, e.g., 1923.
Example:
object_info = { "catalog_number": "CJC-010", "description": "poker chip", "type": "Foreign Body", "year_removed": 2002 }
Access and Print Information:
Use dictionary key access to print the following sentence using the data in
object_info
:โThe item CJC-010 is an poker chip classified as a Foreign Body, removed in 2002.โ
The statement should be saved to the variable
print_statement
, we have provided the code to print the statement for you.
Modify the Dictionary:
Update the
year_removed
to1925
.Print the updated dictionary.
Add a New Key:
Add a new key called
condition
with the value โGoodโ to the dictionary.Print the updated dictionary.
...
# Access and Print Information
print_statement = ...
# We have provided the code to print the statement
print(print_statement)
# Modify the Dictionary
...
# We have provided the code to print the updated dictionary
print("Updated Dictionary:", object_info)
# Add a New Key
...
# We have provided the code to print the updated dictionary
print("Updated Dictionary with Condition:", object_info)
grader.check("chevalier-jackson-dictionary")
Submitting Assignment#
Please run the following block of code using shift + enter
to submit your assignment, you should see your score.
from pykubegrader.submit.submit_assignment import submit_assignment
submit_assignment("week2-lecture", "9_dictionaries_q")