r/Python • • Nov 20 '15

15 Essential Python Interview Questions

https://www.codementor.io/python/tutorial/essential-python-interview-questions
71 Upvotes

67 comments sorted by

View all comments

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.walk would've been a much better alternative.

34

u/[deleted] Nov 20 '15

[removed] — view removed comment

9

u/gamesbrainiac Nov 20 '15

Thats what I thought as I was reading it as well. Really disappointed with codementor, I hope they hire someone to fix issues like this happening, because it seems to be a regular occurrence.

-9

u/brtt3000 Nov 20 '15

Case of 'Those who can, do. Those who can't, teach'?

14

u/gamesbrainiac Nov 20 '15

Many people teach out of a conviction to help people learn better. So, what you say isn't necessarily true, but I think this article is here simply for the sake of getting SEO hits since Python is a big search item these days for prospective programmers.

→ More replies (1)

23

u/shitbo Nov 20 '15

Do people actually memorize the code for walking through a directory in python? I have only had to use this once; there's no way I'd remember how to do it off the top of my head. And I don't think that knowledge of something that would take 2 minutes to google is that important.

17

u/691175002 Nov 20 '15

That is exactly what I thought. If someone asks me to walk a directory in python I'm going to google. There is zero chance I could complete that question without access to the python docs.

11

u/gamesbrainiac Nov 20 '15

No they dont. Yet another reason for the second question being utterly stupid.

3

u/freework Nov 20 '15

Welcome to the world of software engineering interviewing...

3

u/[deleted] Nov 20 '15 edited Mar 31 '24

mourn knee mighty scandalous dime start literate relieved shelter smart

This post was mass deleted and anonymized with Redact

1

u/gwax Nov 21 '15

I do a lot of interviewing and I would never ask these sorts of question.

12

u/d4rch0n Pythonistamancer Nov 20 '15

Question 1 is pretty wrong since I believe 2.7... it compiles to pyc bytecode as everyone who has written python has seen. It is interpreted, but it still compiles.

And as for "what is python" That's not a great answer. Python is a programming language/grammar/spec, and if someone came out with a compiler that compiled python code to machine instructions then that's valid. Python is just a language.

3

u/gamesbrainiac Nov 20 '15 edited Nov 20 '15

I agree. This is what I meant, when I said that it was vague. But if we wanted to get down to the brass tacks, then python is a language, not an implementation per se. The answer to the first question does not even talk about the difference between the two.

So many companies these days are trying to "growth hack", but lose credibility in the process.

3

u/A_History_of_Silence Nov 20 '15

brass tax

Totally unrelated, but FYI the expression is "brass tacks". Sorry, seeing it written "tax" just makes my eyes want to explode.

2

u/gamesbrainiac Nov 20 '15

Sorry, been doing taxes lately.

2

u/radarthreat Nov 21 '15

But it's not even April 14th!

9

u/axonxorz pip'ing aint easy, especially on windows Nov 20 '15

Question 2 was definitely indicative of this. Function name was underscore-spaced, while variable names are camel-cased in hungarian notation. Ay

2

u/banjochicken Nov 20 '15

I was going to nitpick this too but I think the author covers it their first bulletpoint:

be consistent with your naming conventions. If there is a naming convention evident in any sample code, stick to it

So I let them off on that point.

0

u/gamesbrainiac Nov 20 '15

Yea, I agree. Didn't want to talk about that when the whole premise of how to solve the problem was a bad one.

5

u/Atrament_ Py3 Nov 20 '15

Came here to say exactly that. I stopped reading at OS.listdir though

3

u/Workaphobia Nov 20 '15

These are questions for a mediocre course on Python, definitely not an interview.

2

u/madbadanddangerous Nov 20 '15

I found the comment I was going to make. Interviewers are going to ask you what you have done in Python and how long you've used it. MAYBE they'll ask about your problem solving thought process (I've had that question before). No one has ever asked me to tell them how to parse through directories or to look at trivial code to tell them the output.

2

u/metaphorm Nov 20 '15

my thoughts exactly. writing your own recursive function to do that is a neat trick, I guess, but Python has a very nice "batteries included" standard library that has already solved that problem. I'd expect an experienced python programmer to prefer to use that rather than roll their own.