



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These lecture notes cover the topic of dictionaries in the cpsc 121 fall 2012 course, including their basics, syntax, unique keys, and operations. The notes also provide an overview of exam 3, including its format and covered topics.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Today
Reading
Homework
Basics
Topics
Note:
Every key is unique in a dictionary
d = {โaโ: 1, โbโ: 2, โaโ: 3}
d {โaโ: 3, โbโ: 2}
Dictionaries support many of the same operations as lists
d = {โaโ: 1, โbโ: 2, โcโ: 3}
d[โaโ] # subscript 1
d[โdโ] = 1 # add a key-value pair d {โaโ: 1, โbโ: 2, โcโ: 3, โdโ: 1}
d[โaโ] = 2 # set a key value d {โaโ: 2, โbโ: 2, โcโ: 3, โdโ: 1}
d.get(โaโ) 2
d.get(โeโ, 0) # alt value 0
โaโ in d # key in dictionary True
โeโ in d False
โeโ not in d True