Preparing for a Python Developer Interview

Introduction

In this article I will be giving my opinions and suggestions for putting yourself in the best position to out-perform competing candidates in a Python programming interview so that you can land a job as a Python developer.

You may be thinking, with the shortage of programmers in the job market all I need to do is show up and answer a few questions about basic Python syntax and let my degree or bootcamp certificate take care of the rest. Well let me be the first to tell you that is very unlikely to be the case, and even if it does work you are not likely to stay employed for long once the other members of your team realize you don't have the chops to cut it on their team.

So, if you are looking to break into the Python programming space or even move up to a senior Python developer role, I invite you to keep reading as I layout some important tips for being as competitive as possible in the interviewing game.

Know your way around Python

Seems obvious if you have applied to a job listing for a Python developer role that you should probably know Python. However, if you do not and you managed to bluff your way into an interview without the necessary knowledge of Python, you have some serious effort to put in. You better block out some significant time immediately to get up to speed on at least the basics of Python and realize that unless you have years of experience in another high-level, object oriented, programming language (i.e. Java, JavaScript, C#, etc...) you probably stand very little chance of doing well enough in this interview to land the job. Sorry for the bad news... stop lying on job applications.

At the very least you should be able to white board out some idiomatic Python constructs like loops, control flow structures, list comprehensions, and define some basic classes. If any of this is not sounding familiar I recommend you head over to Scott Robinson's Python Tutorial for Absolute Beginners article here on StackAbuse.

Showcase your Example Projects

I realize that you have been busy with school, a coding bootcamp, or your current / previous job, but I cannot stress the importance of this enough. When you are applying for a Python developer job you are effectively trying to convince the hiring manager that you possess the skills they need to make a significant contribution to a product or a project that will someday be a product that brings value to that company.

From my experience the best way to prove you can code is to hand over a reasonable amount of code that demonstrates your ability to produce a usable piece of software. This could be a simple web application, data processing script, or minimal desktop application. The key here is to give an idea of your ability to write code that is well organized, idiomatic, and readable.

The best way to do this is to have a public GitHub, BitBucket, or GitLab repository that houses your example project(s). This does a few things for you:

  • It puts you in the open source community which in and of itself is a great thing.
  • It demonstrates that you also know the basics of Git version control.
  • It gets your name out there and increases your chance of being contacted for jobs as well.

Regarding the second point, when you are building your example code project, treat it like a real project. Complete small pieces of functionality at a time and then commit them to version control with descriptive commits. You will be surprised at the effect of this. Hiring managers place high value on your understanding and ability to use Git version control.

Brush up on Data Structures and Algorithms

First off you should know the common Python data structures such as lists, dictionaries, tuples, and how to create classes.

Next, you should know the more generalized data structures such as linked lists, stacks, and queues that are not necessarily implemented in the Python standard library, but can be implemented using the language.

You should also be able to compare and contrast the basic Python data structures with the aforementioned generalized data structures and describe how you can either use existing Python data structures such as lists to implement the functionality of a stack, or on the other hand, do a custom implementation of a class like a LinkedList.

Below is an example of a custom implementation of a linked list, which utilizes an Element (also referred to as Node) internal class to manage data elements.

class Element:  
    def __init__(self, value):
        self.value = value
        self.next = None

class LinkedList:  
    def __init__(self, head=None):
        self.head = head

    def append(self, value):
        if self.head is None:
            self.head = Element(value)
        else:
            current = self.head
            while current.next is not None:
                current = current.next
            current.next = Element(value)

    def pop(self):
        if self.head is None:
            return None

        if self.head.next is None:
            value = self.head.value
            self.head = None
            return value

        current = self.head
        while current.next.next:
            current = current.next
        value = current.next.value
        current.next = None
        return value

    def peek(self):
        if self.head is None:
            return None
        current = self.head
        while current.next:
            current = current.next
        return current.value

    def remove(self, value):
        if self.head is None:
            return None

        if self.head.next is None:
            if self.head.value == value:
                self.head = None
                return True
            return None

        if self.head.next.next is None:
            if self.head.next.value == value:
                self.head.next = None
                return True

        current = self.head
        while current.next.next:
            if current.next.value == value:
                current.next = current.next.next
                return True
            current = current.next
        return None

    def insert_first(self, value):
        next_element = self.head
        self.head = Element(value)
        self.head.next = next_element

    def delete_first(self):
        if self.head:
            new_first = self.head.next
            self.head = new_first

You should be able to identify instances where it would be beneficial to use a particular data structure, like a linked list.

For example, if you know you will be inserting and deleting items from the front of a list often then it is significantly more efficient to use something like a LinkedList over a the standard Python list. However, it's worth mentioning that such an operation is most commonly used with a queue or a stack, which a LinkedList can be used for, but the Python collections module already has a built-in data structure useful for this called deque which would be important to bring up also during the discussion with the interviewers.

The primary objective of bringing up the custom implementation of a LinkedList in a Python interview would be to demonstrate your ability to code up a custom class and describe the differences between the standard Python list and the mechanics of a LinkedList.

Also, be aware of some basic algorithms that are used to perform common tasks such as sorting and searching.

For example, it would be good to explain how and why a binary search performs significantly better than a linear search in a list. Specifically, a linear search will always be O(n) while a binary search is O(log n). You would also want to explain when it is appropriate to use a binary search over a linear one. In cases where you expect to be searching a moderately large list many times it is likely worth the expense incurred to sort a list and make it capable of binary searches, but if a list is to be searched only a couple of times it may not be worth the expense of sorting it. Also worthy of a mention is to contemplate whether it is better to just use another data structure such as a dictionary in cases where the key you are searching on is a hashable structure, which will essentially give you O(1) item lookups and insertions.

Ability to Comprehend and Solve Problems

Being a rock star developer is much more than just memorizing a particular language's syntax or commonly used data structures and algorithms, however valuable that may be. The thing that will differentiate you from the crowd is your ability to comprehend a problem, use case, opportunity to be implemented in software, or whatever else you may refer to the things we are asked to translate into code.

What this requires is a combination of both hard and soft skills. You need to be able to actively listen to the feature requirement or bug description and identify the pertinent facts, and ask questions to drive out additional key aspects. Then you need to be able to break all that information down into individual tasks or components that can be carried out to then collectively work together to perform the desired functionality.

Believe me, this is ultimately what an employer wants to test you on, how you handle being presented with a programming task or problem and your ability to identify key pieces of information and use it to devise a solution.

This is easier said than done. However, there are a few things that will increase your likelihood of success, namely by putting in lots of practice and getting exposure to a variety of problems. The more problems you are exposed to the more you are able to start recognizing common patterns in problems and reoccurring solutions that often vary only minimally. A great way to gain experience solving programming problems is to use a service like Daily Coding Problem.

The Daily Coding Problem is a service that you can signup for which will email you a different programming problem presented in Python every day for you to solve. For example, the home page of The Daily Programming Problem gives an example of the types of problems you can expect to receive such as, "There's a staircase with N steps, and you can climb 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters".

Interestingly, the permutations of different step combinations simplifies to a summation of the combinations of steps for (N - 1) + (N - 2) which you might recognize as the primary logic for implementing the algorithm for a Nth number Fibonacci sequence.

Let me elaborate more on this.

How many different ways can you climb one (N = 1) stair taking 1 or 2 steps at a time? A set of exactly one [1].

N = 1 => [1]  

Now how about two stairs (N = 2)?

N = 2 => [1, 1], [2]  

Then for a formula of f(N) = f(N - 1) + f(N - 2) as long as N > 0

[1] + ([1,1], [2]) = [1,1,1], [1,2], [2,1] 

As I mentioned earlier, this is the recursive implementation of the Fibonacci sequence and in Python it looks like this.

def step_combinations(stairs):  
    if stairs <= 1:
        return 1
    return step_combinations(stairs - 1) + step_combinations(stairs - 2)

With Daily Coding Problem, not only will you get practice problems every day, but you can also get detailed solutions to those problems, for a small discounted fee, to help you solve the extra tricky problems or let you compare your solutions to those provided by the service.

Icing on the Cake

Since this is an article on interviewing for a Python job I have been focussing on Python-specific technical skills, however in my experience, rarely will a Python developer actually only code in Python. In fact, its probably not even a good idea from a long-term employability standpoint to think you will only ever work with one technology or programming language.

My advice is to pay attention to the ancillary technologies that are often on the job listing in sections like "Nice to haves", which may list things like JavaScript, CSS, Java, etc... and be prepared to lightly delve into those as well. This shows you are able and willing to learn other things that will bring value to the company you are applying for.

Another beneficial things to do is to have some knowledge of the company. Do some basic research on the company you have applied to work for. Focus on things like identifying key revenue streams and any culture identities the company may have or are trying to establish.

Last but not least, I would like to touch on dressing for an interview. It should go without saying that it pays to dress to impress but, I have actually heard of and seen developers show up to interviews in jeans and hoodies... Doinke! At the very least, if the company's culture is loose enough, you should dress in business casual, but I still recommend a suit. You have already put in the effort to be able to show off your mad Python skills and wow them with your knowledge of the company, so don't blow it by leaving them with the lasting impression of "yea he seemed like he knew about programming, but so did the other N candidates who looked like they didn't just wander in from the arcade".

Simply put, take pride in your appearance and not just your Python skills.

Conclusion

In this article I have tried to articulate what I have come to find are key differentiators that can put you ahead of the competition while interviewing for a Python developer role. I have mentioned the importance of actually knowing Python, the usefulness of common data structures and algorithms, becoming a better problem solver by exposure to many problems via services like The Daily Coding Problem, and even the basics such as company research and appropriate attire. I hope you found some value in this article but, most of all I hope it helps you nail that upcoming Python interview.

As always I thank you for reading and welcome comments and criticisms below.

Resources

Author image
Lincoln, Nebraska Twitter