Skip to Content
Hash Maps: Python

Now that we have all of the functionality of a Hash Map, it’s time to review what we’ve learned!



Create a hash map hash_map. Give it an array size over 15.


Assign the following key-value pairs to hash_map:

  • Key: 'gabbro', Value: 'igneous'
  • Key: 'sandstone', Value: 'sedimentary'
  • Key: 'gneiss', Value: 'metamorphic'

Retrieve the value from each of the three keys from hash_map. Print them out!


Congratulations! You implemented a fully-functional hash map! Some things to consider:

  • How would you delete a key-value pair from this hash map?
  • Parts of the code are a little repetitive, how would you factor these roles differently?
  • What should your hash map do if a key-value is added and the array is full? How does this hash map handle that?
Folder Icon

Sign up to start coding

Already have an account?