Professional Documents
Culture Documents
Dictionaries - Activities
PART A
In [2]: return_dict = {'Fund A': 0.057,
'Fund B': 0.059,
'Fund C': 0.34,
'Fund D': 0.199,
'Fund E': 0.203
}
PART B
In [5]: #2. create a new dictionary 'totalReturn_dict' with
# 'Total' as key
# sum of return_dict values as value
## PART A
return_dict = {'Fund A': 0.057,
'Fund B': 0.059,
'Fund C': 0.34,
'Fund D': 0.199,
'Fund E': 0.203
}
In [6]:
returns = {0.057 : 'Fund A',
0.059 : 'Fund B',
0.34 : 'Fund C',
0.199 : 'Fund D',
0.203 : 'Fund E'
}
#3. switch the keys and values in dictionary returns
# keys will now be the values
#values will now be the keys
d2 = {'Apple': 175,
'Blackberry': 57,
'Celcuity': 231,
'Discovery': 219,
'ElectroCore': 3700,
'FedEx': 38,
'XBiotech': 732}
d3 = {'Apple': 126.02,
'Blackberry': 9.04,
'Celcuity': 14.50,
'Discovery': 43.90,
'ElectroCore': 2.06,
'FedEx': 282.88,
'XBiotech': 16.97}
In [ ]: