IT 117: Intermediate Scripting
Quiz 1 Answers


  1. What are the entries in a dictionary?
    key-value pairs
  2. Do the entries in a dictionary have a definite order?
    no
  3. 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']
  4. If I wanted to add the email address 'dave.souza@gmail.com' to the dictionary emails using the key 'Dave', what Python statement would I write?
    emails['Dave'] = 'dave.souza@gmail.com'
  5. 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'
  6. Write the Python statement to create an empty dictionary named students.
    students = {}
  7. Write the Python expression you would use to test whether the students dictionary contains an entry for a student with the ID '0456234'.
    '0456234' in students
  8. Write the Python expression you would use to test whether the students dictionary does not contain an entry for a student with the ID '0497234'.
    '0497234' not in students
  9. Write the Python statement you would use to delete the entry in the students dictionary with key value '0456234'.
    del students['0456234']
  10. What would happen if you tried to delete a dictionary entry using a key that was not in the directory?
    you would get a KeyError exception