Python top interview questions 2022

After working with python for so many years in the industry, I have curated a list of python interview questions for both freshers who are starting their careers and also for experienced developers who are applying for a senior position. I have tried to mark all my questions with relevant experience levels for a job interview.

Unfortunately, I am not able to write the answers for each and every question but, I would try to add answers to all the python interview questions slowly.


What are decorators? Can you explain it in layman terms and give a code example you have used?

Experience Level - All levels

What is a generator? Give an example of generators.

Experience Level - All levels

What is an iterator? How is it different from generators?

Experience Level - All levels

What is the purpose of __pycache__ the folder?

Experience Level - Intermediate

What does the __init__.py do?

Experience Level - All levels

Difference between list and array in python?

Experience Level - All levels

Array vs List in Python
Array is a vector containing homogeneous elements, i.e same data types. All theelements are saved in continuous memory location so it has a better performanceto lists in python. One important thing here we have to remember that whilecreating an array we have to import the array built-in module an…

Difference between set, list, tuple, array in python

Experience Level - All levels

Give an example of immutable data type in python.

Experience Level - All levels

The most common answer in interviews, which people give is tuplewhile this would work, there is always a follow-up question on what does immutable data type mean and does python have any other data type which is immutable. String, Yes! a string is an immutable datatype, in python, when you modify the content, then a new string object is created.

What is list comprehension? Why should we use list comprehension?

Experience Level - All levels

Does python support functional programming? Explain filter, map reduce, lambda in python?

Experience Level - Intermediate

Explain Deep copy and Shallow copy.

Experience Level - All levels

Explain __slots__ keyword concept.

Experience Level - Experienced

Explain __all__ keyword concept.

Experience Level - Senior Position

How does the python interpreter resolve the import of modules?

Experience Level - All levels

What does if __name __ == "__main__" mean?

Experience Level - All levels

Explain the use of break, continue and pass keyword?

Experience Level - All levels

What does *args and **kwargs signify in function definition? Can I use some other name in place of args and kwargs?

Experience Level - All levels

What do you mean by context manager? What does with keyword do?

Experience Level - Senior Position

Explain the use case of global and nonlocal in python

Experience Level - Senior Position

What does globals() and locals() method do in python?

Experience Level - Senior Position

Difference between @classmethod and @staticmethod?

Experience Level - All levels

Difference between def __init__(self) and def __new__(self)

Experience Level - All levels

Difference between def __str__(self) and def __repr__(self)

Experience Level - All levels

What does self and cls signify in Python Object Oriented Programming (OOP) concept?

Experience Level - All levels

What does @property decorator do?

Experience Level - Senior Position

Explain multiple inheritances? Does python support multiple inheritances?

Experience Level - Senior Position

What is the use case of super keyword in python?

Experience Level - All levels

What is the difference between Python Modules and Packages?

Experience Level - All levels


If you are looking for Django related interview questions you should check out my curated list of interview questions for Django

Django Top Interview Questions 2022
After working with Django for 5+ years and taking numerous interviews, I have realised that the questions one can ask in Django Interview are very limited. I have been on both sides of the table and to be honest, there are just a handful number of questions that one can