Python Questions that HCL Interviewer Asked me in my 1st Interview

Hi,

If you are planning to join the IT companies out there, you must do two things:

  1. Create a CV, or resume, and mention all the skills that you have, in it.
  2. Upload your CV on Naukri.com, and other portals.

Once you do that, you will receive a number of calls if you have the desired skills. I received an email from HCL for an interview for the post of Python Developer.

It was the first round of the interview, and they asked me three questions.

  1. Do you have the experience of working with AWS and Azure?
  2. Middlewares in Django
  3. Which one is a valid dicitonary – a) dict = {‘A’:[1,2,3], [2,3,4]:(2,3)}, b) dict = {‘A’:[1,2,3], [2,3,4]:(2,3), (2,3): ‘B’ }, c ) dict = {(1,4): [1,2,3], (2,3,4):(2,3)}

They asked the 1st question because, he said, they are looking for people with experience with AWS. Now, I had no experience with AWS, so I said, No. It is best to say ‘No’, the truth if you don’t have the experience. I don’t expect them to hire me, but at least I would have the respect. Now, if you are preparing for HCL, maybe you should at least about AWS, and explain it a bit if they ask you about it.

The 2nd question is from Django – a web framework written in Python. A middleware is exactly what the name suggests – something that comes in the middle. It can be a function or a class that comes in between the submission of an HTTP request and the execution of the view function. Middlewares have some specific functions to provide various checks on the request. It is easy to plug in or plug out a middleware, simply by adding their name in the list of MIDDLEWARES in the Settings.py file.

The 3rd question is about dictionaries in Python. For the solution of this question, one must remember one single thing, that a list can not act as a key of a dictionary. If you don’t agree, please go to your IDE, and try to create and print a dictionary that has a list as the key. You will get an error. The reason is that a dictionary can only have hashable data types as its key. Strings, Integers, tuples, etc. are hashable, hence one can use them as keys. The list is mutable, and hence they are not hashable. If someone asks you – ‘Why a Python list can not act as a dictionary key?’, the answer would be the same as explained above.

I hope this write-up helps you in your next interview, and if it does kindly share it with others as well.

Leave a Comment

Your email address will not be published. Required fields are marked *

PHP Code Snippets Powered By : XYZScripts.com