Intermediate Python
Hugo Bowne-Anderson
Data Scientist at DataCamp
world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21}
world["albania"]
2.77
world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21, "albania":2.81}
world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
{0:"hello", True:"dear", "two":"world"}
{0: 'hello', True: 'dear', 'two': 'world'}
{["just", "to", "test"]: "value"}
TypeError: unhashable type: 'list'
world["sealand"] = 0.000027
world
{'afghanistan': 30.55, 'albania': 2.81,
'algeria': 39.21, 'sealand': 2.7e-05}
"sealand" in world
True
world["sealand"] = 0.000028
world
{'afghanistan': 30.55, 'albania': 2.81,
'algeria': 39.21, 'sealand': 2.8e-05}
del(world["sealand"])
world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
Indexed by range of numbers |
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
Indexed by range of numbers | Indexed by unique keys |
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
Indexed by range of numbers | Indexed by unique keys |
Collection of values — order matters, for selecting entire subsets |
List | Dictionary |
---|---|
Select, update, and remove with [] |
Select, update, and remove with [] |
Indexed by range of numbers | Indexed by unique keys |
Collection of values — order matters, for selecting entire subsets | Lookup table with unique keys |
Intermediate Python