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

6

u/nate256 Apr 10 '19 edited Apr 10 '19

1 Given a file, write a function which accepts a version number, date and returns pass or fail? Hope you didn't miss this one.

import random
GIVEN_FILE = "a.txt"
def function(version, date):
    return random.choice(["pass", "fail"])

2

def revsenwords(sen):
    return " ".join(reversed(sen.split())

def revsenchars(sen):
    return "".join(reversed(sen))

3

[x for x in basics]

2

u/zr0gravity7 Apr 10 '19

in an interview wouldn't you opt to use a list comprehension or iterator for part 2 rather than a built in method. JUst to flex knowledge

1

u/Decency Apr 11 '19

Flexing knowledge means using the right tool for the job, not the most complicated one you know. ESPECIALLY in Python.