From: geremy condra on 6 Aug 2010 16:28 On Fri, Aug 6, 2010 at 11:45 AM, James Mills <prologic(a)shortcircuit.net.au> wrote: > On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase <python.list(a)tim.thechases.com> wrote: >>> I would like to aquint myself with Python Interview questions >> >> This came up a while ago: >> >> http://www.mail-archive.com/python-list(a)python.org/msg168961.html >> >> Most of that thread is still relevant (perhaps throw in some py3l questions >> too) > > A common thing you can do in interviews is ask > your interviewee to write (in Python) a solution > to the "FizzBuzz" problem. Any good competent > Python programmer should be able to do this > in 5-10mins (5 if you're good). > > cheers > james If I had to wait 5 minutes while a candidate tried to solve this problem I would not hire them. One minute, fine- maybe you're just a little rusty or nervous, or the rare person who has to back away from real-world programming concerns to deal with a trivial problem like this. If English isn't your native tongue I might double or even triple that. Otherwise, no way- I'm going to spend more time hanging over your head than you'll save me. Geremy Condra
From: James Mills on 6 Aug 2010 16:37 On Sat, Aug 7, 2010 at 6:28 AM, geremy condra <debatem1(a)gmail.com> wrote: > If I had to wait 5 minutes while a candidate tried to solve this > problem I would not hire them. Yes you do raise a valid point. It should really only take you a mere few seconds or so to write a solution to this. More over, it can be done in just a single line of Python. 7 if you're not very familiar with Python. cheers James -- -- James Mills -- -- "Problems are solved by method"
From: Steven D'Aprano on 6 Aug 2010 21:25 On Sat, 07 Aug 2010 06:37:05 +1000, James Mills wrote: > On Sat, Aug 7, 2010 at 6:28 AM, geremy condra <debatem1(a)gmail.com> > wrote: >> If I had to wait 5 minutes while a candidate tried to solve this >> problem I would not hire them. > > Yes you do raise a valid point. It should really only take you a mere > few seconds or so to write a solution to this. Yes, but the point is to come up with a solution that is *correct*, not merely a solution. *wink* Just the mere typing time will be "a few seconds or so", so you're leaving zero time for actual thought, let alone running the code at least once to test it. Personally, I'd rather see how a potential hire *tests* his code than how he writes it. Writing code is easy. Testing code is harder. Testing it properly is harder still -- it's amazing how many people forget that it's not just necessary to test the function on data that *works*, but also on data that fails as well (unless, of course, you're happy with function behaviour that is unspecified in the face of errors). I also want to see when the coder thinks she's done. If I say "Write a function that does fizzbuzz", does she assume I want *just* the function, or does she ask questions like "Do you want documentation and tests? What sort of tests?". Does she assume that because the fizzbuzz function is small it doesn't need documentation or testing? The Fizzbuzz algorithm itself is the simple part. If I'm hiring a coder, I care more about their attitude to documentation and testing than their ability to code up a tiny algorithm in five seconds time. I want to see if they are a careful coder, or a cowboy. > More over, it can be done in just a single line of Python. > > 7 if you're not very familiar with Python. Or if you value readability over conserving newlines. Some months ago I wrote a version of FizzBuzz. By the time I read the description of the problem, re-read it to make sure I understood it and looking for any hidden traps ("seems too simple to me, what have I missed?"), wrote a first draft, tested it, fixed a silly typo, and then tested it again, it took about 3-5 minutes. I don't believe I have anything to be ashamed about that, especially not when I look at the number of comments by people who claimed the exercise was so trivial that they did it in ten seconds, AND GOT IT WRONG. Then I added error checking, tests and documentation, and the whole exercise took about 20 minutes. That was probably overkill, but I was bored :) (At least I didn't turn it into a class.) -- Steven
From: Roy Smith on 6 Aug 2010 22:04 Steven D'Aprano <steve(a)REMOVE-THIS-cybersource.com.au> wrote: > Personally, I'd rather see how a potential hire *tests* his code than how > he writes it. Writing code is easy. Testing code is harder. Testing it > properly is harder still -- it's amazing how many people forget that it's > not just necessary to test the function on data that *works*, but also on > data that fails as well (unless, of course, you're happy with function > behaviour that is unspecified in the face of errors). > > I also want to see when the coder thinks she's done. Perhaps I'm reading more into your choice of words than you intended, but I'm curious what you envision a "coder" does. I think of "coder" and a rather low-level job. Somebody who just writes code. I'm generally looking for somebody who is more of a software engineer. Somebody who is not just writing some code, but who is building a product. That means, as you suggest, that it's documented, tested, robust, maintainable, portable, all that good stuff. > If I say "Write a function that does fizzbuzz", does she assume I > want *just* the function, or does she ask questions like "Do you want > documentation and tests? What sort of tests?". I think this depends on the situation. For writing code at a whiteboard while i watched, I'd expect the candidate to concentrate just on the code itself. If it was an assigment, as in, "Write a program to do X, and mail it to me by tomorrow", I'd expect a much more complete treatment.
From: geremy condra on 6 Aug 2010 22:26
On Fri, Aug 6, 2010 at 6:25 PM, Steven D'Aprano <steve(a)remove-this-cybersource.com.au> wrote: > On Sat, 07 Aug 2010 06:37:05 +1000, James Mills wrote: > >> On Sat, Aug 7, 2010 at 6:28 AM, geremy condra <debatem1(a)gmail.com> >> wrote: >>> If I had to wait 5 minutes while a candidate tried to solve this >>> problem I would not hire them. >> >> Yes you do raise a valid point. It should really only take you a mere >> few seconds or so to write a solution to this. > > Yes, but the point is to come up with a solution that is *correct*, not > merely a solution. *wink* > > Just the mere typing time will be "a few seconds or so", so you're > leaving zero time for actual thought, let alone running the code at least > once to test it. I wouldn't let them have access to an interpreter for this either. The goal is to see if they can put out something that looks reasonably close to a solution; if so, they're probably trainable. Otherwise, GTFO. > Personally, I'd rather see how a potential hire *tests* his code than how > he writes it. Writing code is easy. Testing code is harder. Testing it > properly is harder still -- it's amazing how many people forget that it's > not just necessary to test the function on data that *works*, but also on > data that fails as well (unless, of course, you're happy with function > behaviour that is unspecified in the face of errors). Absolutely. A great problem for this is the ACM programming challenge pig latin translator- it contains a logic error that makes a certain case ambiguous. Hire the ones that spot the problem before they touch the keyboard on the spot, and put the ones that test for it at the top of the heap. > I also want to see when the coder thinks she's done. If I say "Write a > function that does fizzbuzz", does she assume I want *just* the function, > or does she ask questions like "Do you want documentation and tests? What > sort of tests?". Does she assume that because the fizzbuzz function is > small it doesn't need documentation or testing? The Fizzbuzz algorithm > itself is the simple part. If I'm hiring a coder, I care more about their > attitude to documentation and testing than their ability to code up a > tiny algorithm in five seconds time. I want to see if they are a careful > coder, or a cowboy. I have things I'd rather do than sit around and watch a candidate write tests. If I wanted them to write tests, I'd send them the problem before the interview and have them sell me on their way of solving it during the interview. > >> More over, it can be done in just a single line of Python. >> >> 7 if you're not very familiar with Python. > > Or if you value readability over conserving newlines. I was thinking the same thing. > Some months ago I wrote a version of FizzBuzz. By the time I read the > description of the problem, re-read it to make sure I understood it and > looking for any hidden traps ("seems too simple to me, what have I > missed?"), wrote a first draft, tested it, fixed a silly typo, and then > tested it again, it took about 3-5 minutes. I don't believe I have > anything to be ashamed about that, especially not when I look at the > number of comments by people who claimed the exercise was so trivial that > they did it in ten seconds, AND GOT IT WRONG. Given the expectation of interpreter-ready code rather than just logically correct and close enough, 3 minutes isn't insane. 5 minutes is still pretty out there, though. Of course, getting it wrong doesn't win anybody points. > Then I added error checking, tests and documentation, and the whole > exercise took about 20 minutes. That was probably overkill, but I was > bored :) Just maybe ;) Geremy Condra |