-
What are the entries in a dictionary?
key - value pairs
-
Do the entries in a dictionary have a definite order?
no
-
Are dictionaries sequences?
no
-
If I had a dictionary of email addresses named emails,
what would I write to get the email for the person named 'Chris'?
emails['Chris']
-
Write the Python statement to create an empty dictionary named
empty.
empty = {}
-
Write the Python statement to change the value for 'Dave' in the dictionary above
to 'dave.souza@hotmail.com'
emails['Dave'] = 'dave.souza@hotmail.com'
-
Write the Python statement you would use to create the dictionary
integer_words, where the key is an integer
and the value is the name of the number. Do this for the first 3 integers.
integer_words = {1:'one', 2:'two', 3:'three'}
-
What happens when you try to get a value from a dictionary using a key that
is not in the dictionary?
you get a KeyError exception
-
Write a
for
loop that prints all the keys in the dictionary
emails.
for key in emails:
print(key)
-
Write a
for
loop that prints all the values in the dictionary
emails.
for key in emails:
print(emails[key])