This is an assessment based on Jeremiah Lant’s Concept map for Python dictionaries.
- Suppose a dictionary
fruit
was created as follows:
<br /> fruit = {}<br /> fruit['pear'] = 2<br /> fruit['banana'] = 6<br /> fruit['ananas'] = 1<br />
You iterate over the keys in this dictionary with a loop:
for fruit in fruit
What do you get?</p>- pear, banana, ananas (the order the keys been set)
- ananas, banana, pear (alphabetical order)
- ananas, pear, banana (the order of the values)
- The order is implementation dependent and you do not know
- You are given two lists
a
andb
, one of which (a
) you want to use as keys and the other (b
) as the values of a dictionaryd
, always pairing up a key froma
with a value fromb
. Implement at least two different ways of constructingd
.