How to Interview a Python Developer and What to Look For?
Python is one of the most highly appreciated general-purpose programming languages in use today. Easy to learn, highly productive, and pleasant to use—it’s wildly popular amongst developers across every skill level. It’s important to remember, however, the difference between knowing how to write Python code and engineering systems using the language.
We’ve already covered why and how you should go about Hiring Python Developers, but what about when it comes to the interview? A good technical interview should separate the experienced Python engineer from those who have used the language occasionally or are merely familiar with its syntax.
By the end of the interview process, you should come away with a firm idea of a candidate’s abilities, their level of experience, and an idea of how well they might fit in as a member of the team. Achieving all these goals, in just the few hours you have available, isn’t a trivial task.
Getting a good result from the technical interview means starting with questions about previous work and past projects before finding out a candidate’s knowledge on the fundamental principles and practices of Python engineering. It means assessing an applicant’s problem-solving abilities, soft skills, and communication under the pressure of an interview environment.
Outlined here are the questions you can ask, qualities you should look for, and skills you should aim to find to identify the ideal Python developer to join your firm. Alternatively, just tell us what you need and within 72h we can connect you with up to 5 companies that match your needs—all for free.
Python Development Skill Set
Before you start interviewing any potential developers, it’s important to answer some questions of your own. Think about the position you're hiring for and the kind of developer you imagine would fit into that role.
Python is an exceptionally broad language. It’s routinely used for tasks ranging from worldwide service deployment to the creation of internal tools and prototype demonstrations. In different scenarios, it can be an object-oriented platform, a simple scripting language, procedural language, or a functional one.
It’s precisely because there’s no single-use case for Python development and that there’s also no single kind of Python developer. Knowing the role Python is likely to play in your firm, at least for the near future, will help shape the qualities and skills you can look for in a potential candidate.
Internal questions to ask of your firm include:
- What role does Python play in the development process?
- What libraries and frameworks are in use already?
- What shape might our Python development take in the future, and what technologies will support it?
Technical Qualities of a Python Developer
Before an applicant has even come in for an interview, you should already have a rough idea about how well they can code. You should know of the work they’ve done before and the kinds of projects and technologies that interest them personally and professionally. Online profiles, Github, and similar resources are ideal tools to get to know a candidate early in the process.
The kinds of projects they undertake in their free time, or open-source contributions they’ve made in previous companies, can tell you a lot about their technical abilities and interests. Also, as mentioned, you can simply tell us what you need and we’ll do all the legwork for you, for free! After 72h we’ll connect you with up to 5 companies that have the background that matches your requirements!
When it comes to the interview, this is a conversation that should go both ways. You’d expect a thorough candidate to have researched your company before applying for the role or attending for an interview.
Informally introducing the firm by talking about the company’s work, projects, and technologies you have in common is a great way to break the ice before jumping into more in-depth and detailed technical topics later.
Discussing a candidate’s portfolio is an ideal starter topic; you’ll gain a greater understanding of their role in projects, and they’ll get a chance to talk about some of their best work.
Python’s Libraries and Frameworks
At the heart of the many diverse use cases of the Python language are the diverging libraries and frameworks that it supports (for more about the latter, check out our Ultimate Guide to Python Frameworks in 2021). A python developer with some professional experience is likely to have worked with a few that relate directly to their field.
Asking questions about these tools can give you an insight into the kind of work they’ve done in the past. It’s an insight into the topics they are confident about and how well they communicate complex technical subjects with a team that may not know a great deal about them.
The right answer should break down the relevant libraries to be easy to understand at a relatively high level. It should be clear, opinionated, and offer up alternatives that developers could also investigate.
Questions on Python’s libraries may include:
- Describe a typical case where you may use NumPy over SciPy, or vice-versa
- What type of project might TensorFlow be ideally suited to? What other technologies might be used instead? Why?
- What are some of the primary differences between Django and Flask? Where might you use one over the other?
Python Interview Questions
To add to a high-level understanding of the projects a candidate has worked on in the past—it can be helpful to find out how well they can describe and discuss the language. Fundamental questions can be a useful insight into a developer’s understanding.
More than simply using Python as a tool, a high-quality Python engineer should know the details of the language from the ground up. Listed below are some Python development questions and a selection of sample answers that should help to investigate these skill sets.
What is Python, what are its advantages and drawbacks, how does it compare to other languages?
Some aspects of the Python language that a candidate may want to mention:
- Python is object-oriented. It allows for the definition of classes, composition, and inheritance.
- Python handles memory automatically in a managed heap space. This contrasts with languages such as C, or C++ particularly sharply.
- Python is very productive; it’s quick to write and capable of doing a lot with only a few lines of code.
- One of the primary drawbacks of Python code is that it’s considerably slower in execution than languages such as C, or C++.
How effective is multi-threading in Python? Can it be used to speed up code?
Python can be multi-threaded, but it’s a poor way to optimise code for speed.
Python uses a Global Interpreter Lock that ensures safety by ensuring only one thread can execute at a time. This means threads take turns using one CPU core at a time, prohibiting parallel computation and adding additional overheads. Python’s threading package is suited to IO or networking, but it’s not useful as a performance tool.
Python code may call other functions (such as a C function) to do multi-threading performance calls if required.
How is memory managed in Python?
Memory management in Python is done with a private heap space. Objects and data structures are stored in a private heap that the programmer can not access directly.
This is another way that Python aims to abstract obstacles away from the developer, preferring to handle memory automatically instead.
How does garbage collection work in Python?
Python retains a count of references to each object. If an object’s reference count reaches zero, then the object is no longer considered live, and its memory is freed for other tasks.
Recently created objects are prioritised for garbage collection over older ones.
Are there any issues that Python’s garbage collection has to overcome?
Occasionally reference cycles happen; this means the reference count is greater than zero, but references are only held between objects that each have no other references to them in memory.
object1.x == object2
object2.x == object1
The garbage collector periodically checks for these conditions and removes them.
What is pickling and unpickling?
Pickling is the process of taking a Python object and converting it into a string representation for storage. Unpickling is the reverse process of taking the string representation and converting it back into an object in Python.
This has uses in making temporary storage and debugging code relatively simple.
What is init in Python?
init is a method or constructor in Python. This method is automatically called to allocate memory when a new object or instance of a class is created. All classes have the init method.
An example of init in Python:
def __init__(self, name, position,salary):
self.name = name
self.position = position
self.salary = 60000
E1 = Employee("XYZ", "Senior Engineer", 60000)
# E1 is the instance of class Employee.
#__init__ allocates memory for E1.
Object Oriented Python
As we’ve shown, Python has an exceptionally broad range of use cases. It’s often called on to do everything from quick and simple ‘hacks’ to data analysis, scripting, feature implementation, and everything in-between.
These wide ranges of uses for the language betray the fact that it is also a highly capable language for large engineering tasks. It’s one that your developers should know in full.
Listed here are some questions related to using Python as an object-oriented language for application development.
Explain the inheritance supported by Python
Inheritance allows a class to gain all the attributes and methods of another class without writing the same code twice. Inheritance promotes reusability and makes it easier to maintain an application. The class we are inheriting from is the super-class, and the class that is inherited is the child class.
They are different types of inheritance supported by Python:
- Single inheritance – where a derived class acquires the members of one super-class.
- Multilevel inheritance – A child class has a superclass that is a child class of another.
- Hierarchical inheritance – from one base class, you can inherit any number of child classes.
- Multiple inheritance – a derived class is inherited from more than one base class. Python differs from a language such as Java in supporting multiple inheritance.
Describe polymorphism in Python
Polymorphism allows child classes to modify the methods it inherits from its parent. For example, a child class may have a method with the same name as its parent but may wish to add its own parameters and variables to that method.
How do you achieve data abstraction in Python?
Data abstraction is centred around exposing only the required details of a class and hiding the detail of its implementation. Developers can achieve data abstraction in Python by using interfaces and abstract classes.
Define encapsulation in Python?
Encapsulation is about binding the code and the data of a program together. A Python class is an example of encapsulation.
Python Coding Skills
As with most technical and practical skills, there’s no substitute for physically doing the task and solving real-world problems. For this reason, practical coding examples are the most valuable part of any technical interview.
With an eye on practical coding, it’s important to make enough time to undertake pair or solo programming exercises and discuss, review, and modify the solutions after.
The very best problems are the domain-specific ones that come from your own codebase. Problems your developers have already tackled and solved in the past are especially well-suited to provide a non-trivial example. Talking about real code is invariably a step up from toys and demonstrations.
However, if none of these are available, we’ve included some small challenge programs you may ask a candidate to implement with only 10-15 minutes required for the task.
FizzBuzz in Python
The single most common coding interview question in any language, most candidates will be familiar with this task, even if they’ve not personally encountered it before.
The rules are that candidates should iterate over a predefined list of numbers, and:
- Replace all integers that are evenly divisible by 3 with “fizz”
- Replace all integers divisible by 5 with “buzz”
- Replace all integers divisible by both 3 and 5 with “fizzbuzz”
- Avoid using range() in their answer (This is optional but adds an extra step of complexity)
An example solution is included below:
numbers = [25, 76, 15, 13, 11, 5, 0, 9]
for i, num in enumerate(numbers):
if num % 3 == 0 and num % 5 == 0:
numbers[i] = 'fizzbuzz'
elif num % 3 == 0:
numbers[i] = 'fizz'
elif num % 5 == 0:
numbers[i] = 'buzz'
output: ['buzz', 76, 'fizzbuzz', 13, 11, 'buzz', 'fizzbuzz', 'fizz']
A palindrome is a sequence of letters that reads the same forward and backwards, such as ‘pip’. A relatively simple and self-contained exercise would be to ask candidates to implement a python function that checks a sequence of letters to determine if they are, in fact, a palindrome.
The simplest example might be:
if not string[left]==string[right]:
Either of these tasks could be modified with extra steps, challenges, or tests to stretch a candidate’s abilities a little further under pressure.
Non-Technical Python Skills
Technical skills are, in reality, only one part of the equation when it comes to hiring a developer in any language. Personality and soft skills play just as large a role.
While engineering abilities define how well a developer will work on code, soft skills will define how well a team works together. The latter is undoubtedly the most valuable asset to the larger company.
Many of the technical questions already covered will go some way to investigating a developer’s soft skills. Analyse, not just the content of a candidate’s answers, but the way they present technical information, communicate solutions with the group, and convey new information to an audience.
These skills, though often overlooked, are a fundamental part of software development. The response and intuition you get today is the best insight you’ll get before investing time and money into hiring a new candidate.
Some additional soft skill questions you might ask developers to get their insight on the topic could include:
- What impacts have you made on previous companies you have joined?
- Have you ever worked on a team with drastically conflicting opinions on tackling a technical issue? How was it resolved?
- What do you think makes a strong collaborative team?
Looking into the future
Additional skills a valuable candidate should have would include keeping up to date in an industry that is continually evolving and changing month to month. A broad awareness of the direction languages, tools, and technologies are moving in is essential for any high-quality engineer.
Attempting to gauge the enthusiasm a candidate has for the topic is a very difficult skill to master, but there are a few key topics and questions that can help:
- What changes to Python 3 have you really appreciated in using the language?
- What are your favourite Python projects on Github in recent years?
- What Python projects have you been impressed by and what ones would you like to learn more about?
A Checklist for Choosing the Ideal Python Developer
A strong Python developer has a general problem-solving ability that matches the language they use. They should have a broad set of skills and an ability to tackle a great breadth of development challenges. Some fundamental traits of the ideal Python developer might include:
- Used a broad range of libraries and frameworks in the past;
- Solid understanding of object-oriented programming;
- Follows best practices in code;
- Communicates well on technical topics and problem-solving processes;
- Strong interpersonal skills at interview;
- Opinionated choices on favoured technical solutions and ways of working;
- Has abundant code samples or a rich portfolio of work;
- High-quality work on test assignments; and
- Up to date on industry topics and recent technologies.
Python is such a popular, easy to learn, and widely adopted language that there are millions of developers out there with some understanding of its features. In finding the ideal candidate, you need more than that.
You need a candidate with an in-depth understanding of the features of Python and the libraries, frameworks, and platforms that support it. You need a strongly opinionated candidate, one found through careful and considerate interview, one that can engineer complex solutions and deliver maximum value for your firm.
Sounds like a lot, right? Well never fear, you can always refer back to this article or our Comprehensive Guide to Hiring Python Engineering Teams to make sure you have it all straight.
Need help selecting the right company?
We will do the work for you, all for free.
Tell us what you need