These are related to my concept map on python dictionaries.
1. You have executed the following line of code in python to create a dictionary:
d = {‘name’ : ‘Matthew’, ‘computer’ : ‘Mac’, 1 : ‘complete’, 2 : ‘incomplete’}
Which of the following lines of code would give an error if you executed them?
a) print d[‘name’]
b) print d[‘Mac’]
c) print d[‘computer’] + ‘book’
d) print d[0]
e) b and d
f) b, c, and d
2. Which of the following are valid dictionary assignment statements in python?
a) d[ (3, 4, [5, 6]) ] = (8, 7)
b) d[ (1, 3, (9, 10)) ] = [4, 7, (8, 9)]
c) d[ lambda x : x ] = lambda x : x**2
d) a and b
e) b and c
f) a and c