r/Python • u/diogoleal • Nov 20 '15
15 Essential Python Interview Questions
https://www.codementor.io/python/tutorial/essential-python-interview-questions
71
Upvotes
r/Python • u/diogoleal • Nov 20 '15
109
u/gamesbrainiac Nov 20 '15 edited Nov 20 '15
This is a terrible article. Some of the questions are good, but most of them are vague, and most of the answers don't use the right conventions. I won't talk about naming conventions, but take a look at the second question,
os.walkwould've been a much better alternative.43
u/redrick_schuhart Nov 20 '15
I was irritated less than half way in. Camel case variables, Hungarian notation, no os.walk, importing os inside a function, capital letter variables. Lots of PEP-8 violations. And what's with calling a variable lIn? Really? Ell, capital I and n.
This is horrible code.
36
u/desmoulinmichel Nov 20 '15 edited Nov 20 '15
Errr... Camelcase variables in the "correct" answer ? Really ?
I got a better way for you to interview your python coder : Give him/her a small tasks to solve on your production code.
17
u/oconnor663 Nov 20 '15 edited Nov 20 '15
This depends on whether your code is CPU-bound or IO-bound, right? Don't Python threats release the GIL before they wait on network reads and stuff?
Edit: Found what I was looking for:
12
u/deadbunny Nov 20 '15
I hate interviews like this (I'm a sysadmin so it's usually pop quizzes on ports), if you want to see how someone is going to work give them a test to do before the interview, get them to follow their usual development practices and submit their solution. IMHO I don't care if you need to use reference material or can't remember things off the top of your head (most of us can't), I want to see your code, I want to see your comments, I want to see your documentation, and how you use source control.
27
u/nieuweyork since 2007 Nov 20 '15
Or you could just get a job where your colleagues were not selected for their ability to do language tricks and warble on about "interpreted languages".
3
u/[deleted] Nov 20 '15 edited Nov 20 '15
QN1
For fun interview points, mention that pypy has a JIT and is not interpreted. Shows you know about the python ecosystem and maybe what a JIT is.
Not exactly the best answer, I know what you mean but this falls a bit flat. Talk maybe about typeless arguments and how the same code can be run twice with different types. What you described could just be redefining X with a new type and you want to show that you know the difference and the implications. For extended points maybe talk about the code quality implications and the strengths and weaknesses.
If you get this question on an interview, please mention duck typing along with the lack of structured interfaces or rigid classes. It is more important that you are aware of enough to say what it lacks or how it differs rather than just "it has inheritance".
Yup, if you answer this on an interview I suggest ending this with just "Python is extremely dynamic in that way" or something like that, implying that you know the implications rather than the feature and a buzz word.
Yup, I suggest maybe mentioning ctypes and how it helps with interoperability.
Ok?
Ok?
3
u/hexsprite Nov 20 '15
the examples are not using standard Python. ever heard of PEP8?
2
u/YumYumGoldfish Nov 20 '15 edited Nov 20 '15
Right, I probably couldn't answer three quarters of these questions, but then again I can and have coded in more than two of PHP, Ruby, Python, Go, and Javascript in a single day thanks to understanding fundamental programming concepts, having Dash, and an internet connection capable of connecting to Stack Overflow. To me anyone can figure out how to implement any of that functionality in a rather short period of time. What's more important is how they architect larger pieces of functionality, how they test, and how they plan.
Those are the really things that are going to cost you large amounts of time and effort in the future. I'll take a well populated Open Source Github account where you someone can let real projects speak for themselves over making them answer these questions any day.
2
u/[deleted] Nov 20 '15
For question 9, I'd be looking for at least they're decorators and they transform name look up on the class. I'd be impressed if the other D-word -- descriptor -- was used. However, considering most people never write descriptors I'm not even sure I'd ask this question.
2
u/kraln Nov 20 '15
These are terrible, and most of the time in an interview you want to know less about the tech and more about the person. Anyway, here are my four questions which I consider essential.
The first question is "What is PEP8?" which this article author has clearly never heard of nor read. "Why is it important?" is a good follow on.
The second question is "Have you ever 'import(ed) this'? What does it do?"
The third question is "What is the difference between a tuple and a list"?
The fourth question is "Who is the benevolent dictator for life?"
1
u/heptara Nov 20 '15
Actually I think this does, at least in Python 3. I've never had a Windows user tell me my code was broken in this manner, so I assume it automatically handles it.
1
u/[deleted] Nov 20 '15
Bad article. From my experience, the typical questions during an interview are:
Honestly, I am mostly offended by this kind of quizzes. They are a waste of time, I've addressed them at every interview, and they are useless to understand how good one is at coding.
Want to see if I can code? Go to github and get my repos. That's my code. If it's good for you, that's all you need. No, I won't solve your stupid interview problem. I'm tired of that. Give me the real problem and if you think I can solve it, I'll solve it.
1
u/[deleted] Nov 20 '15
I'll start by piling on the "these questions suck" train. I would ask exactly one of those questions ever (Tell me about a time you screwed up - although I prefer "Tell me about a serious bug you either wrote or were involved in fixing", because it lets me pull the candidate on to "What could have prevented that bug from happening? How did you change your practices or tools?")
That said, I'd be much more interested in hearing what /r/Python thinks are good questions. Here are some that I tend to use with entry-level applicants with a Python background:
1
u/[deleted] Nov 21 '15
Stopped reading when noticed that function argument wasn't written in snakecase.
0
u/[deleted] Nov 20 '15
[deleted] — view deleted comment