Dictionaries Concept Video Activity

Time: 5-10 minutes

Purpose: Give you practice with using Dictionaries in python.

Introduction: Try to work out the following tasks in python and run them to make sure they do what you expect.

Tasks:

  1. Assign the value ‘hello’ to the key ‘beginning’ in the following dictionary
    messages = {}
  2. Assign the value ‘good-bye’ to the key ‘ending’ in the same dictionary
  3. Print the value of the key ‘beginning’ from the dictionary
  4. Print out the keys of the following dictionary (use a loop)
    d = {1:'a',2:'b',3:'c'}
  5. Print out the values of the previous dictionary (using a loop)

Further learning resources:

A file showing a possible solution is available on github here