Analytics Vidhya
Published in

Analytics Vidhya

Recreating Python Dictionaries from Scratch

Wondering how to do that?! Well, then continue reading… :)

As it is well known that Python Dictionaries are a data structure which are used to store key-value pairs; where “keys” are used to store and retrieve the stored “values”. For example, here is a dictionary for storing and retrieving the marks of students in a class;

Still wondering? How this works? Read ahead… :)

  • Dictionaries in Python are implemented using a data structure called hash table.
  • A hash table uses a list/array to store the key-value pairs, and uses a hashing function to determine the index for storing or retrieving the data associated with a given key.

After implementing the above function we can create Python Dictionaries as follows →

And DONE! The dictionary data structure in Python was successfully created from scratch :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store