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:
- Assign the value ‘hello’ to the key ‘beginning’ in the following dictionary
messages = {}
- Assign the value ‘good-bye’ to the key ‘ending’ in the same dictionary
- Print the value of the key ‘beginning’ from the dictionary
- Print out the keys of the following dictionary (use a loop)
d = {1:'a',2:'b',3:'c'}
- 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