This community-built FAQ covers the “Creating the Hash Map Class” exercise from the lesson “Hash Maps: Python”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Complex Data Structures
FAQs on the exercise Creating the Hash Map Class
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
Can someone please explain step 3 of this exercise? I dont understand why this step must be taken:
Create an instance variable called
.array , which is a list of size
array_size . Make each element of
.array equal to
I know this reply arrived wayyyy too late but maybe it’ll help for future learners:
I think “None” here represents a default value or an “empty slot” in our array, which can be filled with data later. And we put it in range(self.array_size) because we can’t have more emty slots than the size of our array.
That’s how I understand this
I don’t think these lessons make it clear enough that Python is being used as merely as a tool to illustrate how this data-structure functions. I would suggest a more clear statement at the outset, such as “in Python, efficient key-value storage via hash-maps is already accomplished via the built in dictionary Data-Type, that you will already have learned about by now. For that reason, this exercise is focusing on teaching you the general principles of how hash-maps may be implemented across different programming languages. In practice with Python, you’ll likely want to use the built-in dictionary class for most purposes.”
self.array = [None] * array_size
This is a bit easier syntax…
Is this a correct statement about Python? It is from the lesson ‘Creating the Hash Map Class’.
“In Python we don’t have an array data structure that uses a contiguous block of memory.”
The following article says the opposite about Python arrays:
“This is because Python arrays use contiguous blocks of memory, which makes them easier to access and process.”
Source: Introduction to Python arrays
So, which one is true about Python arrays?