IT 117: Intermediate to Scripting
Answers to Class 5 Ungraded Quiz

  1. What are the entries in a dictionary?
    key - value pairs
  2. Do the entries in a dictionary have a definite order?
    no
  3. Are dictionaries sequences?
    no
  4. 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']
  5. Write the Python statement to create an empty dictionary named empty.
    empty = {}
  6. 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'
  7. 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'}
  8. 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
  9. Write a for loop that prints all the keys in the dictionary emails.
    for key in emails:
        print(key)
  10. Write a for loop that prints all the values in the dictionary emails.
    for key in emails:
        print(emails[key])