These questions are for Jeremiah’s concept map on Python dictionaries.
Question 1
Suppose you have a Python dictionary that’s defined as follows:
test_dictionary = {<br />
'who': 'first',<br />
'what': 'second',<br />
'i_dont_know': 'third',<br />
}
You want to access the value of “i_dont_know
”. Which of the following would work to access the value? Select all that apply.
A. test_dictionary[i_dont_know]
B. test_dictionary['i_dont_know']
C. test_dictionary[3]
D. test_dictionary[-1]
E. test_dictionary.'i_dont_know'
Question 2
Launch Python, and define test_dictionary
as above. Then add several more key / value pairs to it. Type test_dictionary.
(with the dot at the end) and press the tab key twice. You’ll see a list of all of the things you can do with test_dictionary
. Use one of those operations to print just the values (without their keys) from the dictionary. Then do print test_dictionary
and print [the code you came up with to show just the values]
and show the results.