/Assignment_5

Primary LanguageJupyter Notebook

Assignment_5

  1. What does an empty dictionary's code look like?

  2. What is the value of a dictionary value with the key 'foo' and the value 42?

  3. What is the most significant distinction between a dictionary and a list?

  4. What happens if you try to access spam['foo'] if spam is {'bar': 100}?

  5. If a dictionary is stored in spam, what is the difference between the expressions 'cat' in spam and 'cat' in spam.keys()?

  6. If a dictionary is stored in spam, what is the difference between the expressions 'cat' in spam and 'cat' in spam.values()?

  7. What is a shortcut for the following code? if 'color' not in spam: spam['color'] = 'black'

  8. How do you "pretty print" dictionary values using which module and function?