Test Yourself
Use Nested Dictionaries to create a shop with multiple items and give them multiple parameters. Once this is done, try and use loops and the methods we learnt to display the keys and values.
In the code given for Tic-Tac-Toe, modify it by using Dictionaries.
What does the code for an empty dictionary look like?
- What is the main difference between a dictionary and a list?
- If a dictionary is stored in spam, what is the difference between the expressions 'cat' in spam and 'cat' in spam.keys()?
- If a dictionary is stored in spam, what is the difference between the expressions 'cat' in spam and 'cat' in spam.values()?
- What is a shortcut for the following code?
if 'color' not in spam:
spam['color'] = 'black'
- What module and function can be used to “pretty print” dictionary values?