Insights
Python Screening Interview questions for DataScientists
5 min read
By Julien Kervizic

DataScience requires an interdisciplinary set of skills, from handling databases, to running statistical model, to setting up business cases and programming itself. More often than not technical interviews for data-scientists assess more the knowledge of specific data manipulation APIs such as pandas, sklearn or spark, rather than a programming way of thinking.

While I think that a knowledge of the more “applied” APIs is something that should be tested when hiring data-scientist, so is the knowledge of more traditional programming.

String Reversal & Palindrome

String reversal questions can provide some information as to how well, certain candidates have been with dealing with text in python and at handling basic operations.

Question 1:

Question: Reverse the String “ “the fox jumps over the lazy dog”

Answer:

Assessment:

  • This is more of a warmup question than anything else and while it is good to know the shortcut notation, especially as it denotes some knowledge of how python deals with strings (eg substr a[0:7] for the fox) it is not necessary for most data-science’s purpose

Question 2:

Question: identity all words that are palindromes in the following sentence “Lol, this is a gag, I didn’t laugh so much in a long time”

Answer:

Assessment:

  • Does the candidate thinks about cleaning his/her inputs?
  • Does the candidate know the basic or word processing in python such as replace / split / lower?
  • Does the candidate know how to use list comprehension?
  • How does the candidate structure his/her code?

FizzBuzz

FizzBuzz is a traditional programming screening question, that allows to test if a candidate can think through a problem that is not a simple if else statement. The approach that they take can also shed some light to their understanding of the language.

Question: Write a program that prints the number for 1 to 50, for number multiple of 2 print fizz instead of a number, for numbers multiple of 3 print buzz, for numbers which are multiple of both 2 and 3 fizzbuzz.

Answer:

Assessment:

  • Do they know the modulo operator and are able to apply it?
  • Are they storing the result of the modulo operators in variables for re-use?
  • Do they understand how True/False interact with a String?
  • Are they bombarding their code with if statements
  • Do they return a consistent type or mix both integer and string?

First Duplicate word

First finding of duplicate word allows to identity if candidates know the basic of text processing in python as well as are able to handle some basic data structure.

Question 1:

Question: Given a string find the first duplicate word, example string: “this is just a wonder, wonder why do I have this in mind”

Answer:

Assessment:

  • Do I have constraint I need to work with, for instance in terms of memory?
  • Cleans the string from punctuation? Replace or Regexp? If use regexp replace, should I compile the regexp expression or used it directly?
  • Knows the right data-structure to check for existence.
  • Does it terminate the function as soon as the match is found or?

Question 2:

Question: What if we wanted to find the first word with more than 2 duplicates in a string?

Answer:

Assessment:

  • Some small modification is needed to be able to accommodate that change, the main one is arising from the use of a dictionary data-structure rather than a set. Counters are also a valid data-structure for this use case.
  • There is little difficulty on modifying the previous function to cope with this change request, it is worth checking that the candidate does instantiate the specific key correctly, taking into account default values.

Quick Fire questions

Some quick fire questions can also be asked to test the general knowledge of the python language.

Question 1:

Question: Replicate the sum for any number of variables, eg sum(1,2,3,4,5..)

Answer:

Assessment:

  • Quick interview question to check the knowledge of variable arguments, and how to setup one of the most basic functions.

Question 2:

Questions around the Fibonacci series is a classic of programming interviews and candidates should in general be at least familiar with them. They allow to test recursive thinking.

Question: Fibonacci sequences are defined as follow:

Write a function that gives the sum of all fibonacci numbers from 0 to n.

Answer:

Assessment:

  • First, is the candidate able to think recursively?
  • Is the candidate only thinking about a naive solution to the sum of fibonacci series or is s/he understanding that it can also summarized to a in a more effective way?

Wrap up

These questions are just meant to be a first screener for data-scientist and should be combined with statistical and data manipulation types of questions. They are meant to give a quick glimpse on whether a candidate has the basic minimum knowledge to go through a full interview rounds.

More advanced programming questions for Python would tend to cover the use of generators, decorators, cython or the efficient use of libraries such as pandas/numpy.

Privacy Policy
Sitemap
Cookie Preferences
© 2024 WiseAnalytics