Preparing for a Python skills Test

Hi Everyone,

After a recent interview, I’ve been selected to be tested for my Python skills. So I wanted to write about how I am preparing for this. There are many angles from which you can tackle preparation for such a task. By no means is this an exhaustive list of preparation methods. Instead, I offer a few angles to take for now and will update this post as more occur to me.

Reaching out to people in your Network

If you have that knowledgable contact, perhaps someone who has experience running interviews for a data science role, reach out to them and ask them kindly if they would go through a mock interview with you. If not then it can also be useful to find test questions online and ask an understanding friend to go through them with you.

Reaching out to people in your field and letting them know that you are preparing for a test can be useful as people are generally willing to offer helpful resources. I find that there’s always a helpful resource that I have not yet heard about.

Testing yourself with Online resources

After asking around and explaining my upcoming challenge to other Python-savvy people in my network, I was recommended to check out codewars.

A quick look at the site shows me that this is a pretty great resource for people in my situation who need to sharpen their skills and practice their language. They offer challenges for almost thirty languages and 22 more which are in beta access. Their motto is ‘Achieve mastery through challenge’. Below is a snapshot of a question for the Python language.

Highly recommended!

Take a Ten Minute Walk Test

You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones — everytime you press the button it sends you an array of one-letter strings representing directions to walk (eg. [’n’, ‘s’, ‘w’, ‘e’]). You always walk only a single block for each letter (direction) and you know it takes you one minute to traverse one city block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you don’t want to be early or late!) and will, of course, return you to your starting point. Return false otherwise.

Note: you will always receive a valid array containing a random assortment of direction letters (’n’, ‘s’, ‘e’, or ‘w’ only). It will never give you an empty array (that’s not a walk, that’s standing still!).

The code you are given, to begin with:

def is_valid_walk(walk):
#determine if walk is valid

So I figure we need to make sure that the value of the length of ‘walk’ is = ten. A conditional can do just that. It will help control the flow of the logic.

def is_valid_walk(walk):
#determine if walk is valid
if len(walk) != 10:
return False

Now I’ve made sure the length of my walk will be correctly scrutinised, I need to make sure that the function verifies if I end up at the start again or not.

Using some paper and a pencil or some kind of graph paper really helps with this. I traced some example ten-step walks to understand what sort of patterns I get when I return to the start. I realised that the patterns were symmetrical. Take five steps east and five steps west and you’ve returned to the start and the east and west balance out. Is it true if you add north and south in too?

Once I realised the symmetrical logic that obeyed the rules in our ten-step walk, entering the next conditional line of logic in the function was simple:

There are some inconsistencies with the code alignment below as Python users may know. The last ‘walk.count’ is misaligned.

def is_valid_walk(walk):
#determine if walk is valid
if len(walk) != 10:
return False
elif walk.count('e') != walk.count('w') or walk.count('n') != walk.count('s'):
return False

This code prevents any asymmetrical walks from occurring.

There are no more rules so I’ll go ahead and conclude my conditional logic to return ‘True’ if a walk is presented that does not trigger the previous ‘if’ and ‘elif’ statement.

def is_valid_walk(walk):
#determine if walk is valid
if len(walk) != 10:
return False
elif walk.count('e') != walk.count('w') or walk.count('n') != walk.count('s'):
return False
return True

This passes all 210 tests in the Codewars Kata.

General Tips

Listening to Python Podcasts

Whilst it may not help in your immediate effort to practice for an upcoming test, listening to Python podcasts is beneficial in more than a few ways. You may learn things you never knew were possible with Python and gain valuable knowledge to use as conversational material to name a couple. Starting this preparation method early pays off down the line, consider it an investment in your self.

I have listed the Top 10 Podcasts to listen to as Data Scientist in a previous article and you’ll be able to find a couple of Python podcasts among them.

Pythonic Coding

In Python, you can often write things in more than one way. If you already have a decent mastery of the basics in Python it could be worth your time to learn more optimised or efficient methods to write regular code.

These tips from are super useful for developing your pythonic coding and getting ahead of the game.

  • Use enumerate() to iterate over both indices and values
  • Debug problematic code with breakpoint()
  • Format strings effectively with f-strings
  • Sort lists with custom arguments
  • Use generators instead of list comprehensions to conserve memory
  • Define default values when looking up dictionary keys
  • Count hashable objects with the collections.Counter class
  • Use the standard library to get lists of permutations and combinations

Don’t Do

This has been a short compilation of methods to prepare for upcoming Python tests. One thing I won’t recommend if you’re going for a junior or entry-level role particularly is to ready yourself by taking the Linkedin Python mastery test. I tried this test earlier this year and it is not a test aimed at the beginner or intermediate Python user. If this test is something that you found beneficial, this article is likely going to be less useful and all the more strength to you.


  1. Python interview Tips —
  2. Codewars — Language=Python
  3. Top 10 Podcasts for Data Scientists



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store