r/learnpython • • Apr 10 '19

My recent interview experience on Python.

Role: Automation Test Developer.

Questions asked:

1: Basics of Linux, few tricky commands, what are inodes, setting up networking etc etc.

2: Python:

Given a file, write a function which accepts a version 
number, date and returns pass or fail. 

 EDIT:
 the file structure is basically a test result log file which contains lines of information.
 Each line has a version and date, tests run and results. 
 I was supposed to return results which are pass fail based on the version number and date given.:)


Reverse a sentence without using slicing.

List comprehension basics. 

What I did right: I wrote enough code solving pythonic interview problems, and I was comfortable writing the code in the interview.

what I did wrong: Focused too much on interview type problems, like Coin change, linked list etc etc. Should have also focused on some real use cases of python. For example, how to test a code with different inputs, how to parse few lines from a file, how to schedule a cron job etc etc.

TLDR; Don't just bust your head trying to solve interview challenges from cracking the coding interview. Also learn to make some real world programs.

412 Upvotes

83 comments sorted by

View all comments

20

u/too_tired_bicycle Apr 10 '19

This continues to be a problem for me, i.e. real world problems. Too many Python books/lessons/exercises are a bit too theoretical. Too many of them give you the basics and underlying principles and concepts without saying "okay, now here's a real world example of why this is useful." I'd say the same about Linux shell commands and scripting.

For example, I've been reading a book on the Linux shell and it explained how you can write a for loop in bash. And I'm like, okay, that's cool I guess. I know what a for loop is and it's kind of neat that you can do that in bash. But, thankfully, the book went on to give an example of how that could be used in a practical way: by creating 12 directories representing the 12 months of the year all with a single line of code on the command line. I wish I saw more of this.

7

u/PCHarambeRace Apr 10 '19

Let's not forget bash one liners.

for ip in $(seq 0 254); do host 152.105.251.$ip | grep "pointer"; done

Elegant and beautiful.

5

u/Darkaliafr Apr 11 '19

for ip in $(seq 0 254); do host 152.105.251.$ip | grep "pointer"; done

for ip in {0..254} works too in bash.

1

u/manusatx Apr 14 '19

just to give you a real word example for ksh or bash or even python, a lot of database maintenance scripting or job scheduling tools among others can be automated. Such as look in each view and then check each view base tables list and check if a certain column exists in those base tables, the use case being that column is being changed in size or data type, and you dont want the dependent objects to become invalid.

For python, a simple use case is to do a sensitive data search in a bunch of columns across many databases or filesystems. (use regex and implement parallelism the whole search process)

hope this helps, i am sure there are better solutions for each and everything.